I'm asked to look at some Ruby code. The developers run OSX, I'm on Windows. All is working fine on OSX, but I get an error with Scrypt 2.1.1.
I'm asked by Ruby to run: gem install scrypt -v '2.1.1' which results in an error.
When I do gem install scrypt -v '2.1.1' --platform=ruby it's quite the opposite and all the gem is installed.
Now when I recreate the GemFile or update it, I still get an error and it's again suggested to run gem install scrypt -v '2.1.1'.
The output I'm getting is:
Installing scrypt 2.1.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: <MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt
C:/Ruby23-x64/bin/ruby.exe -rubygems <MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake RUBYARCHDIR=<MyProject>/vendor/bundle/ruby/2.3.0/extensions/x64-mingw32/2.3.0/scrypt-2.1.1 RUBYLIBDIR=<MyProject>/vendor/bundle/ruby/2.3.0/extensions/x64-mingw32/2.3.0/scrypt-2.1.1
rake aborted!
LoadError: cannot load such file -- ffi_c
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:6:in `rescue in <top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:3:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-compiler-0.1.3/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
LoadError: cannot load such file -- 2.3/ffi_c
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.10-x64-mingw32/lib/ffi.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/ffi-compiler-0.1.3/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
LoadError: cannot load such file -- ffi-compiler/compile_task
<MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1/ext/scrypt/Rakefile:1:in `<top (required)>'
<MyProject>/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<main>'
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in <MyProject>/vendor/bundle/ruby/2.3.0/gems/scrypt-2.1.1 for inspection.
I've looked and searched on Google and Bing, but nothing resulted in a solution.
Hope somebody in the community here can help me find the resolution.
Thanks,
Iwan
gem install ffi --platform=ruby
gem install scrypt -v 2.2.1
Works for me.
Related
I know very little about ruby and its package management. On a Ubuntu 16.04 system, there seems to be something messed up with different versions of ruby. I tried to run pdfbeads ruby program.
$ pdfbeads -o all.pdf
/home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': iconv will be deprecated in the future, use String#encode instead.
/home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:128:in `require': libMagickCore.so.5: cannot open shared object file: No such file or directory - /home/t/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/rmagick-2.13.4/RMagick2.so (LoadError)
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:39:in `require'
from /home/t/.rvm/gems/ruby-1.9.3-p551/gems/rmagick-2.13.4/lib/rmagick_internal.rb:11:in `<top (required)>'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/gems/ruby-1.9.3-p551/gems/rmagick-2.13.4/lib/RMagick.rb:1:in `<top (required)>'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/gems/ruby-1.9.3-p551/gems/pdfbeads-1.1.1/lib/pdfbeads.rb:35:in `<top (required)>'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/t/.rvm/gems/ruby-1.9.3-p551/gems/pdfbeads-1.1.1/bin/pdfbeads:38:in `<top (required)>'
from /home/t/.rvm/gems/ruby-1.9.3-p551/bin/pdfbeads:23:in `load'
from /home/t/.rvm/gems/ruby-1.9.3-p551/bin/pdfbeads:23:in `<main>'
from /home/t/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
from /home/t/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'
I first found that the default pdfbeads isn't the one for the latest version of ruby, so I call the latter directly:
$ which pdfbeads
/home/t/.rvm/gems/ruby-1.9.3-p551/bin/pdfbeads
$ whereis pdfbeads
pdfbeads: /usr/local/bin/pdfbeads /home/t/.rvm/gems/ruby-1.9.3-p551/bin/pdfbeads
$ whereis gem
gem: /usr/bin/gem2.3 /usr/bin/gem /home/t/.rvm/rubies/ruby-1.9.3-p551/bin/gem /usr/share/man/man1/gem.1.gz
$ gem --version
2.4.3
$ /usr/local/bin/pdfbeads -o all.pdf
Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.2.7
Ignoring nokogiri-1.6.6.2 because its extensions are not built. Try: gem pristine nokogiri --version 1.6.6.2
Ignoring rmagick-2.13.4 because its extensions are not built. Try: gem pristine rmagick --version 2.13.4
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- iconv (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/t/.rvm/gems/ruby-1.9.3-p551/gems/pdfbeads-1.1.1/bin/pdfbeads:35:in `<top (required)>'
from /usr/local/bin/pdfbeads:23:in `load'
from /usr/local/bin/pdfbeads:23:in `<main>'
Hoping to solve the problem, I run the suggested gem command, but what does the error mean here?
$ gem pristine executable-hooks --version 1.3.2
Restoring gems to pristine condition...
Cached gem for executable-hooks-1.3.2 not found, attempting to fetch...
Fetching: executable-hooks-1.3.2.gem (100%)
ERROR: While executing gem ... (Gem::InstallError)
invalid gem: No such file or directory - /home/t/.rvm/gems/ruby-1.9.3-p551#global/cache/executable-hooks-1.3.2.gem
How can I clean up the old version of ruby and its packages, if I only need the newer version?
Thanks.
You are missing some libraries (imagemagick). Please try installing them:
sudo apt-get install imagemagick libmagickwand-dev
After that try again to install your gem.
To cleanup old version of a gem run:
gem cleanup pdfbeads
To uninstall a specific ruby version run:
rvm remove 1.9.3
You can also take a look in the folder /home/t/.rvm/ and clean up by hand. But do that with care. Or just take a look in this folder to find out which ruby versions and gemsets are installed and clean up with the rvm commands.
I'm trying to install and run puma.
My gemfile has the local extracted gems (the server has no internet access and bundler is install via gem install):
gem 'rack', '=2.0.3', :path => "/opt/app-root/src/gems/rack-2.0.3"
gem 'puma', '=3.11.0', :path => "/opt/app-root/src/gems/puma-3.11.0"
I run bundle like so:
bundle install --local --path ./bundle --deployment
Which produces:
Using bundler 1.16.1
Using puma 3.11.0 from source at `/opt/app-root/src/gems/puma-3.11.0`
Using rack 2.0.3 from source at `/opt/app-root/src/gems/rack-2.0.3`
Bundle complete! 2 Gemfile dependencies, 3 gems now installed.
Bundled gems are installed into `./bundle`
Then running:
bundle exec "puma --config puma.cfg"
Produces the problem with the missing ext:
/opt/app-root/src/gems/puma-3.11.0/lib/puma/server.rb:15:in `require': cannot load such file -- puma/puma_http11 (LoadError)
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/server.rb:15:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/runner.rb:1:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/runner.rb:1:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cluster.rb:1:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cluster.rb:1:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/launcher.rb:4:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/launcher.rb:4:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cli.rb:5:in `require'
from /opt/app-root/src/gems/puma-3.11.0/lib/puma/cli.rb:5:in `<top (required)>'
from /opt/app-root/src/gems/puma-3.11.0/bin/puma:6:in `require'
from /opt/app-root/src/gems/puma-3.11.0/bin/puma:6:in `<top (required)>'
from /opt/app-root/src/ruby/vendor/bundle/ruby/2.4.0/bin/puma:22:in `load'
from /opt/app-root/src/ruby/vendor/bundle/ruby/2.4.0/bin/puma:22:in `<main>'
I can find very little information about this issue, except this post https://github.com/bundler/bundler/issues/5398 which may or may not be a similar issue - but I don't know how to resolve it (re-running bundler install doesn't help me!)
By the way, the ext is present in the extracted gem as you'd expect:
opt/app-root/src/gems/puma-3.11.0/ext/puma_http11
The puma11 stuff in ext is a compiled library; the result of that compilation as puma_http11.bundle then gets copied to the lib/puma directory, as part of the installation process. Do you have this .bundle file?
I'm guessing you have a problem or missing steps in your local extraction process to build or copy the native code portions of Gems (including this one) - the Rakefile in the puma repository on Github includes steps to build the native pieces using ragel.
I have upgraded Ruby version to 2.1.0 from Ruby 1.8.7 and installed all dependencies to run a sample Appium test case using Ruby. But I am facing an issue to load nokogiri while running a test case.
I am using
OS: Mac OS - 1.9.2
Ruby: 2.1.0
Appium: 1.2.0
Nokogiri: 1.6.3.1
This works fine on Ruby: 1.8.7.
Error:
Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `require': dlopen(/Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/.rvm/rubies/ruby-2.1.0/lib/libruby.2.1.0.dylib (LoadError)
Referenced from: /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
Reason: image not found - /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:25:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `require'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `require_relative'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `<top (required)>'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `require'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `<top (required)>'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from samle_tests/sign_in_test.rb:10:in `<main>'
Possible Fix 1:
This usually happens when gems are linked wrong, i recommend trying to re-install ruby via rvm.
rvm reinstall 2.1
rvm use 2.1
Make sure all the gems are up to date by running(in your apps directory)
bundle install
Possible Fix 2:
Another common problem is to install rvm as a root user, if you've done this re install rvm.
You can uninstall rvm by running
rvm implode
Follow the steps on the website to install rvm
While making an application in ruby on rails I got the following error:
ajeet#ajeetpc:~$ rails new first_app
/home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- active_support (LoadError)
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/lib/rails_generator.rb:30:in `<top (required)>'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/ajeet/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/railties/bin/rails:16:in `<main>'
Seems like the rails gem is not installed properly. Try to fix it
gem uninstall rails
gem install rails
then run rails new first_app again.
I'm trying to install Chef solo on a VPS. I've installed Ruby and ran the install command for the Chef gems, however, when I check the version of Chef, it says that it can't load the file. I'm following along with the Railscast on the topic http://railscasts.com/episodes/339-chef-solo-basics?view=asciicast, except that I also installed rbenv and Ruby 2.0.0 as a preliminary step.
Can you identify what the cause of this error is?
root#Chef2:~# gem install chef ruby-shadow --no-ri --no-rdoc
Successfully installed chef-11.4.4
Building native extensions. This could take a while...
Successfully installed ruby-shadow-2.2.0
2 gems installed
root#Chef2:~# rbenv rehash
root#Chef2:~# chef-solo -v
/root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- rubygems/format (LoadError)
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/chef-11.4.4/lib/chef/provider/package/rubygems.rb:34:in `<top (required)>'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/chef-11.4.4/lib/chef/providers.rb:60:in `<top (required)>'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/chef-11.4.4/lib/chef.rb:25:in `<top (required)>'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/chef-11.4.4/lib/chef/application/solo.rb:19:in `<top (required)>'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /root/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/chef-11.4.4/bin/chef-solo:23:in `<top (required)>'
from /root/.rbenv/versions/2.0.0-p195/bin/chef-solo:23:in `load'
from /root/.rbenv/versions/2.0.0-p195/bin/chef-solo:23:in `<main>'
Chef 11 is the latest version of chef and is now packaged with an embedded copy of ruby. See the following documentation:
http://wiki.opscode.com/display/chef/Installing+Chef+Client+and+Chef+Solo
What version of rubygem are you using?
Try using rubygems 1.8.25
I think the original poster may have been running into a ruby-2.0/rubygems-2.0 issue like CHEF-3933 on chef 11.4.4 Those have been fixed by now. Chef 11.10.0 supports ruby-2.1 + rubygems-2.2
Gem installs are highly discouraged if there's an omnibus installer. The railscast is now very out of date. Installation should be done with:
curl -L https://www.opscode.com/chef/install.sh | bash -s