How to install ruby(rubygems) with openssl? - ruby

When running rvm rubygems latest I get the error.
How fix it?
Error running 'env GEM_PATH=/Users/sjc/.rvm/gems/ruby-2.0.0-p0:/Users/
sjc/.rvm/gems/ruby-2.0.0-p0#global:/Users/sjc/.rvm/gems/ruby-2.0.0-p0:
/Users/sjc/.rvm/gems/ruby-2.0.0-p0#global GEM_HOME=/Users/sjc/.rvm/gem
s/ruby-2.0.0-p0 /Users/sjc/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /Users/s
jc/.rvm/src/rubygems-2.0.0/setup.rb', please read /Users/sjc/.rvm/log/
ruby-2.0.0-p0/rubygems.install.log
The log (rubygems.install.log) has this:
[2013-03-05 20:31:37] /Users/sjc/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
/Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- openssl (LoadError)
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/security.rb:8:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/package.rb:43:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/installer.rb:8:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/request_set.rb:5:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems.rb:195:in `finish_resolve'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/rdoc.rb:14:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/uninstaller.rb:10:in `<top (required)>'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/commands/setup_command.rb:440:in `uninstall_old_gemcutter'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/commands/setup_command.rb:144:in `execute'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/command.rb:305:in `invoke_with_build_args'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/command_manager.rb:170:in `process_args'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/command_manager.rb:130:in `run'
from /Users/sjc/.rvm/src/rubygems-2.0.0/lib/rubygems/gem_runner.rb:60:in `run'
from setup.rb:45:in `<main>'
RubyGems 2.0.0 installed
Because I didn't know what I was doing, I think my earlier attempt at installing sass may have caused this. I followed these instructions, thus doing these commands earlier in the day.
$ export GEM_HOME=/home/mygemrepository
$ ruby setup.rb --prefix=/home/mystuff
Again, I don't if that matters as GEM_HOME and GEM_PATH seem correct.
$ echo $GEM_HOME
/Users/sjc/.rvm/gems/ruby-2.0.0-p0
$ echo $GEM_PATH
/Users/sjc/.rvm/gems/ruby-2.0.0-p0:/Users/sjc/.rvm/gems/ruby-2.0.0-p0#global

Looks like you're missing openssl. Checkout: https://rvm.io/packages/openssl/

Examples for ruby 2.3.1, or may be other version of ruby.
Without reinstall rvm:
rvm pkg install openssl
rvm install 2.3.1 --with-openssl-dir=$HOME/.rvm/usr
Or with reinstall rvm:
rvm implode
\curl -sSL https://get.rvm.io | bash
rvm pkg install openssl
rvm install 2.3.1 --with-openssl-dir=$HOME/.rvm/usr
Or with custom rubygems for ruby < 2.3:
rvm pkg install openssl
rvm install 2.2.2 --rubygems 2.7.10 --with-openssl-dir=$HOME/.rvm/usr
PS: after all may be reinstall all ruby versions
rvm reinstall all --force

Another possible issue is if your default version of Ruby is old.
Most OS come preinstalled with Ruby, but use an older versions of Ruby (1.8.x), rather than 2.x or even 1.9.x and that may cause the new version of rvm to fail.
$ rvm list
to see the list of ruby versions install, and use ("ruby use uby-1.9.3-p429" equivalent ) to set that and then try :
$ rvm get stable
(get the most recent bugfixes and ruby version updates )
$ rvm rubygems latest
I also changed the default ruby :
$ rvm --default use 1.9.2
worked for me!

Related

Getting ruby related errors while executing puppet -V after puppet client installation

I am trying to install puppet on ubuntu client.
I have executed following steps:
cd /tmp
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
sudo dpkg -i puppetlabs-release-trusty.deb
sudo apt-get update
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev libxslt1-dev ruby-dev
echo "deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free" | sudo tee /etc/apt/sources.list.d/debian_stable.list
sudo apt-get update
sudo apt-get install libaugeas-ruby1.9.1 augeas-tools
sudo apt-get install puppet
I am getting this error:
#ubuntu:~$ puppet -V
/usr/lib/ruby/vendor_ruby/puppet/vendor/safe_yaml/lib/safe_yaml/syck_node_monkeypatch.rb:42:in `<top (required)>': uninitialized constant Syck (NameError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/puppet/vendor/safe_yaml/lib/safe_yaml.rb:197:in `<module:YAML>'
from /usr/lib/ruby/vendor_ruby/puppet/vendor/safe_yaml/lib/safe_yaml.rb:132:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/puppet/vendor/require_vendored.rb:4:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/puppet/vendor.rb:40:in `require_libs'
from /usr/lib/ruby/vendor_ruby/puppet/vendor.rb:53:in `load_vendored'
from /usr/lib/ruby/vendor_ruby/puppet.rb:174:in `<module:Puppet>'
from /usr/lib/ruby/vendor_ruby/puppet.rb:29:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:12:in `<top (required)>'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/bin/puppet:7:in `<main>'
It will be great to point out if I missed anything here.
No version of Puppet supports Ruby 2.2+ at the moment. Even the latest version of Puppet (v4.8) does not support 2.2+:
System Requirements
Ruby
Use one of the following versions of MRI (standard) Ruby:
2.1.x
2.0.x
1.9.3
Note: We currently only test and package with 2.1.x versions of Ruby, therefore we recommend you only use this version. Other interpreters and versions of Ruby are not covered by our tests.
https://docs.puppet.com/puppet/4.8/system_requirements.html#ruby
Solution:
Downgrade to Ruby 2.1.
Alternative Solution:
A solution proposed here to work around the YAML Syck/Psych issue:
https://tickets.puppetlabs.com/browse/PUP-3796
Add to Gemfile:
gem 'safe_yaml', '~> 1.0.4'

Appium: Nokogiri giving load error while running test case

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

gem install of pdf-extract on Macports / Mac OS X Yosemite

I am attempting to install pdf-extract on Mac OS X Yosemite. I assume it's better not to use the /usr/bin/ruby that comes with Yosemite, so I'm using the Macports version, /opt/local/bin/ruby (ver2.1.3).
The installation appears to go fine:
sudo port install ruby
sudo port install rb-rubygems
sudo port select --set ruby ruby21
which ruby #/opt/local/bin/ruby
which gem #/opt/local/bin/gem
sudo gem install pdf-extract
At the end of the last command, the message appears to indicate that all went well:
...
Done installing documentation for Ascii85, afm, commander, hashery, highline, libsvm-ruby-swig, mini_portile, nokogiri, pdf-core, pdf-extract, pdf-reader, prawn, ruby-rc4, sqlite3, ttfunk after 30 seconds
15 gems installed
However, when I attempt to run pdf-extract, I ran into the following error:
$ cd bin/
$ ./pdf-extract extract --titles journal.pdf
/opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:384:in `block in require_program': program version required (Commander::Runner::CommandError)
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:383:in `each'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:383:in `require_program'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/runner.rb:51:in `run!'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in `run!'
from /opt/local/lib/ruby2.1/gems/2.1.0/gems/commander-4.2.1/lib/commander/import.rb:10:in `block in <top (required)>'
/private/tmp/pdfextract/lib/pdf/extract/references/score.rb:11:in `<module:Score>': uninitialized constant Libsvm::Model (NameError)
from /private/tmp/pdfextract/lib/pdf/extract/references/score.rb:4:in `<module:PdfExtract>'
from /private/tmp/pdfextract/lib/pdf/extract/references/score.rb:3:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf/extract/references/references.rb:3:in `require_relative'
from /private/tmp/pdfextract/lib/pdf/extract/references/references.rb:3:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf/extract.rb:10:in `require_relative'
from /private/tmp/pdfextract/lib/pdf/extract.rb:10:in `<top (required)>'
from /private/tmp/pdfextract/lib/pdf-extract.rb:1:in `require_relative'
from /private/tmp/pdfextract/lib/pdf-extract.rb:1:in `<top (required)>'
from ./pdf-extract:5:in `require_relative'
from ./pdf-extract:5:in `<main>'
My question is whether I've done the gem install correctly (and therefore it's probably a bug in pdf-extract) or whether I've messed up something in the installation (or in the file paths).
Side note: the installation folder was initially $HOME/Dropbox/code/ruby/pdf-extract, but I carried out a mv pdf-extract /tmp (to shorten the file paths in the error messages) and re-ran the install scripts (the error message essentially remained the same). I also tried replacing ./pdf-extract with /opt/local/bin/ruby2.1 pdf-extract but it did not help.

cannot load Ruby gems for Chef

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

Why does Rails console say "cannot load such file -- readline"?

I am new to Ruby on Rails, and am using RVM to manage Ruby versions.
My laptop has Ruby1.8.7 installed, but my project is using RVM, Ruby1.9.3 and Rails 3.2.11.
I can't run rails c or rails console without it giving me the following error:
/home/phil/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/phil/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `require'
from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:38:in `require'
from /home/phil/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.11/lib/rails/commands.rb:38:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
You need to have the readline libraries installed when you compile Ruby.
If you are on CentOS/Redhat/Fedora Linux, install the package using:
sudo yum install readline-devel
Or, on Ubuntu, use:
sudo apt-get install libreadline6 libreadline6-dev
and then recompile Ruby.

Resources