[SOLVED] New install of 5.8 fails to install ruby

solved

(Martin) #1

Hi all,

Having successfully installed 5.6 on Ubuntu a few weeks ago I had to wipe that server and reinstall it with CentOS 7. I then followed the instructions to install Opennebula 5.8 using the repositories.
Installing the ON stuff using yum(1) went fine but the ‘install_gems’ script fails with:

1: from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:inrequire’: cannot load such file – zlib (LoadError)
#

ZLib itself is already installed:

# yum list installed | grep -i zlib
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 @anaconda
zlib.x86_64 1.2.7-18.el7 @base
zlib-devel.x86_64 1.2.7-18.el7 @base
#

So I don’t know what’s causing the problem. Can you give me some pointers?

|\/|


(Alejandro Huertas) #2

Hi @MartinW

Could you please send me the output of gem list | grep zlib?


(Martin) #3

It returns nothing:

# gem list | grep -i zlib
#


(Martin) #4

The output from “gem list” is:

# gem list

*** LOCAL GEMS ***

abrt (0.3.0)
bigdecimal (1.2.0)
bundler (1.17.3)
io-console (0.4.2)
json (1.7.7)
nokogiri (1.6.1)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
#


(Alejandro Huertas) #5

Hi @MartinW

Try to install zlib manually using gem install, you need to know the version that fits with your ruby version. Here https://rubygems.org/gems/zlib/versions/0.1.0 you can find more information about the version.


(Martin) #6

That’s worrying:

# gem install zlib
Fetching: zlib-1.0.0.gem (100%)
ERROR: Error installing zlib:
zlib requires Ruby version >= 2.3.0.
# ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
#

I ran “yum update ruby” but it’s at the latest version that is available from the default CentOS repos.

Where would I get a stable-but-more-recent ruby install?


(Alejandro Huertas) #7

Try using gem install zlib -v 0.1.0.


(Martin) #8

No luck. I tried it with version 0.1.0 and 0.0.1, both failed due to the Ruby version:

# gem install zlib -v 0.1.0
Fetching: zlib-0.1.0.gem (100%)
ERROR: Error installing zlib:
zlib requires Ruby version >= 2.5.0dev.
# gem install zlib -v 0.0.1
Fetching: zlib-0.0.1.gem (100%)
ERROR: Error installing zlib:
zlib requires Ruby version >= 2.5.0dev.
# ruby --version
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
#


(Alejandro Huertas) #9

Maybe you can try using RVM (https://rvm.io/) to update your ruby version.


(Martin) #10

Not entirely sure that helped. I used RVM and it installed a newer version of ruby in /usr/local/bin . After fixing some PATH issues I now get a newer version:

# ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
#

Now when I run “/usr/share/one/install_gems” I get:

ruby openssl libraries are needed. They usually come as companion package to ruby.

I ignored that and tried to install the zlib library, but it now fails with:

# gem install zlib -v 0.1.0
ERROR:  Loading command: install (LoadError)
	cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

I get the same error whether I specify the version or not.

I have confirmed that zlib and OpenSSL are installed:

# yum install zlib
...
Package zlib-1.2.7-18.el7.x86_64 already installed and latest version
Nothing to do\#  yum install openssl
...
Package 1:openssl-1.0.2k-16.el7.x86_64 already installed and latest version
Nothing to do
# 

I made sure that autolibs was enabled in case that was the problem and reinstalled ruby and rails, but I still ge the “ruby openssl libraries are needed” error.

I have “openssl-devel” installed (required for ruby, it seems).

I tried “gem install bundler” and it returned

ERROR:  Loading command: install (LoadError)
	cannot load such file -- zlib

which strongly suggests that zlib is required to just get the install command working, so “gem install zlib” is surely never going to work since there is a circular dependency there.

Any other thoughts?


(Alejandro Huertas) #11

As you are using centos, try to install stock ruby and no custom ruby.


(Martin) #12

Hmm, I thought that’s what I had done, but OK, I will see what I can do.


(Martin) #13

OK, I found the problem. I had tried to compile an up to date ruby from source which I thought I had removed, but in fact had not and this was the 2.5 release that I was executing, so the zlib issue was entirely due to the fact hat I had not compiled zlib in to that software.

I removed it, re-ran the RVM install, installed v2.5 and confirmed that it’s working. I then added “rvm use 2.5” to root’s profile as otherwise it insists on using the default ruby.

So I now have root using the correct ruby, but it’s missing the ‘bundler’ script/software/whatever-it-is. A little research gets me “gem install bundler”, so I have that command.

Now, if I run the /usr/share/one/install_gems script as root it says:

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.

although it does install the files. If I run is as my own UID it tells me I have to run the script as root…

Well, I let it run to completion and it looks like it installed OK, but sadly Sunstone fails to start.

I set the oneadmin user so that it is using the correct ruby by adding “rvm use 2.5” to the end of its .bash_profile but it fails to start. Running “systemctl start opennebula-sunstone” fails with the following errors in the messages file:

Mar  5 16:07:49 vmhost abrt[25091]: detected unhandled Ruby exception in '/usr/lib/one/sunstone/sunstone-server.rb'
Mar  5 16:07:49 vmhost abrt-server: Package 'opennebula-sunstone' isn't signed with proper key
Mar  5 16:07:49 vmhost ruby: from /usr/lib/one/sunstone/sunstone-server.rb:88:in `<main>'
Mar  5 16:07:49 vmhost systemd: opennebula-sunstone.service: main process exited, code=exited, status=1/FAILURE
Mar  5 16:07:49 vmhost systemd: Unit opennebula-sunstone.service entered failed state.
Mar  5 16:07:49 vmhost systemd: opennebula-sunstone.service failed.

I don’t know what the issue is and I’m rather poking around in the dark with RVM. It looks like it’s installed OK though, at least I get the right version number:

# ruby -v
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]

Any further thoughts?


(Martin) #14

I poked around some more and found that if I changed to the oneadmin user and ran:
$ /usr/lib/one/sunstone/sunstone-server.rb
then it works fine and I can get the login page up in a browser.

I then ran it using the built-in ruby and it coredumped, which is linked to the error message I see in /var/log/messages. This suggests that the service is not executing oneadmin’s profile before starting the service.

So, how do I get the RVM-installed ruby to be the default one?


(Alejandro Huertas) #15

Hello @MartinW

Could you please send me the output of gem env?


(Martin) #16

Certainly:

# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.9
  - RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.5.3
  - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.5.3/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.5.3/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/rvm/rubies/ruby-2.5.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/rvm/gems/ruby-2.5.3
     - /usr/local/rvm/gems/ruby-2.5.3@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/rvm/gems/ruby-2.5.3/bin
     - /usr/local/rvm/gems/ruby-2.5.3@global/bin
     - /usr/local/rvm/rubies/ruby-2.5.3/bin
     - /usr/local/rvm/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /sbin
     - /bin
     - /usr/sbin
     - /usr/bin
     - /root/bin

(Alejandro Huertas) #17

It seems that you have the ruby installed just on root (USER INSTALLATION DIRECTORY) try to install in oneadmin’s home.

This is an example on centos7:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14.1
  - RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/one/.gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /var/lib/one/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/one/.gem/ruby
     - /usr/share/gems
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

(Martin) #18

Thanks for the suggestion. I ran “rvm remove” as root to get rid of the existing installation, removed the various shell hacks I’d put in to oneadmin’s profile, then ran “rvm install 2.5” as the oneadmin user.

It all seems to be up and running fine now, my “gem env” looks like:
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.9
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-2.5.3
- USER INSTALLATION DIRECTORY: /var/lib/one/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-2.5.3/bin
- SPEC CACHE DIRECTORY: /var/lib/one/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/rvm/rubies/ruby-2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-2.5.3
- /usr/local/rvm/gems/ruby-2.5.3@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/rvm/gems/ruby-2.5.3/bin
- /usr/local/rvm/gems/ruby-2.5.3@global/bin
- /usr/local/rvm/rubies/ruby-2.5.3/bin
- /usr/lib64/qt-3.3/bin
- /usr/local/bin
- /bin
- /usr/bin
- /usr/local/sbin
- /usr/sbin
- /usr/local/rvm/bin
- /var/lib/one/.local/bin
- /var/lib/one/bin

I can access the sunone web interface and I now have it connected to my local virsh installation, so I think we are good!

Thank you very much for your patience and assistance @ahuertas.


(Alejandro Huertas) #19

That’s so nice :smiley: if you have any doubts you can contact me, it was a pleasure to help you @MartinW!