[5.9.90] json gem seems to be missing

I’m trying to install opennebula 5.10 RC (5.9.90-1) on a fresh CentOS 7 install.
Everything is fine until I try to start opennebula-sunstone:

/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- json (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require’
from /usr/lib/one/sunstone/models/OpenNebulaJSON/JSONUtils.rb:19:in <module:OpenNebulaJSON>' from /usr/lib/one/sunstone/models/OpenNebulaJSON/JSONUtils.rb:17:in <top (required)>’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require’
from /usr/lib/one/sunstone/models/OpenNebulaJSON/GroupJSON.rb:17:in <top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/lib/one/sunstone/models/OpenNebulaJSON.rb:20:in <top (required)>’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require’
from /usr/lib/one/sunstone/models/SunstoneServer.rb:19:in <top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/lib/one/sunstone/sunstone-server.rb:111:in

Here is my gem list:

[oneadmin@one0-s324 ~]$ GEM_PATH=/usr/share/one/gems/ GEM_HOME=/usr/share/one/gems/ gem list
*** LOCAL GEMS ***

activesupport (
addressable (2.7.0)
amazon-ec2 (0.9.17)
aws-eventstream (1.0.3)
aws-sdk (2.11.387)
aws-sdk-core (2.11.387)
aws-sdk-resources (2.11.387)
aws-sigv4 (1.1.0)
azure (0.7.10)
azure-core (0.1.15)
builder (3.2.3)
chunky_png (1.3.11)
concurrent-ruby (1.1.5)
configparser (0.1.7)
curb (0.9.10)
daemons (1.3.1)
eventmachine (1.2.7)
faraday (0.17.0)
faraday_middleware (0.13.1)
ffi (1.11.1)
ffi-rzmq (2.0.7)
ffi-rzmq-core (1.0.7)
hashie (3.6.0)
highline (1.7.10)
i18n (0.9.5)
inflection (1.0.0)
ipaddress (0.8.3)
jmespath (1.4.0)
memcache-client (1.8.5)
mime-types (3.3)
mime-types-data (3.2019.1009)
mini_portile2 (2.1.0)
minitest (5.11.3)
multipart-post (2.1.1)
mysql2 (0.5.2)
net-ldap (0.16.1)
nokogiri (
ox (2.11.0)
parse-cron (0.1.4)
polyglot (0.3.5)
public_suffix (2.0.5)
rack (1.6.11)
rack-protection (1.5.5)
rotp (5.1.0)
rqrcode (0.10.1)
scrub_rb (1.0.1)
sequel (5.25.0)
sinatra (1.4.8)
sqlite3 (1.4.1)
systemu (2.6.5)
thin (1.7.2)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
treetop (1.6.10)
trollop (2.9.9)
tzinfo (1.2.5)
uuidtools (2.1.5)
xml-simple (1.1.5)
zendesk_api (1.16.0)

Is that normal ? no json ?

Best regards,

I’ve just manually installed json gem and now sunstone is able to start. Any idea why the opennebula-rubygem-json is missing ?

Hello @madko ,

gem json is default one provided system-wide by package rubygem-json-1.7.7-36.el7.x86_64 which is an essential dependency for whole RubyGems and Ruby itself. For the reference: https://guides.rubygems.org/rubygems-basics/#listing-installed-gems

(Ruby ships with some gems by default, bigdecimal, io-console, json, minitest, psych, rake, rdoc, test-unit for ruby 2.0.0).

That’s why it’s not explicitly specified in Gemfiles and even doesn’t come bundled as our own gem package. But, even if it’s installed as a gem, it’s linked into the base Ruby paths, so that it can be used no matter how locations are configured.


$ ls -la /usr/share/ruby/json.rb
lrwxrwxrwx. 1 root root 43 Nov 15 14:39 /usr/share/ruby/json.rb -> /usr/share/gems/gems

I’m afraid, I can’t reproduce the problem on my clean C7. Can you please check some of following commands, most likely we have missined something important…

$ rpm -qi rubygem-json

### system-wide installed gems
$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
psych (2.0.0)
rdoc (4.0.0)

$ ruby --version
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

$ ruby -rjson -e1

$ GEM_PATH=/usr/share/one/gems/ GEM_HOME=/usr/share/one/gems/ ruby -rjson -e1

Thank you,

Thank you @vholer for your answer.

Rubygem-json is of course installed system wide:

[oneadmin@one0-s324 ~]$ rpm -q rubygem-json

[oneadmin@one0-s324 ~]$ rpm -qi rubygem-json
Name        : rubygem-json
Version     : 2.0.2
Release     : 2.el7
Architecture: x86_64
Install Date: Fri 15 Nov 2019 10:43:45 AM UTC
Group       : Development/Languages
Size        : 112953
License     : Ruby
Signature   : RSA/SHA1, Tue 05 Dec 2017 12:30:13 PM UTC, Key ID 4fd9532751bc2a13
Source RPM  : rubygem-json-2.0.2-2.el7.src.rpm
Build Date  : Thu 10 Aug 2017 10:26:58 AM UTC
Build Host  : c1bj.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CBS <cbs@centos.org>
Vendor      : CentOS
URL         : http://flori.github.com/json
Summary     : JSON Implementation for Ruby
Description :
This is a implementation of the JSON specification according
to RFC 4627 in Ruby.
You can think of it as a low fat alternative to XML,
if you want to store data to disk or transmit it over
a network rather than use a verbose markup language.

[oneadmin@one0-s324 ~]$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
io-console (0.4.2)
json (2.0.2)
psych (2.0.0)
rdoc (4.0.0)

 [oneadmin@one0-s324 ~]$ ruby --version
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

but the sunstone service can’t find it.

[oneadmin@one0-s324 ~]$ ruby -rjson -e1
[oneadmin@one0-s324 ~]$ GEM_PATH=/usr/share/one/gems/ GEM_HOME=/usr/share/one/gems/ ruby -rjson -e1
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- json (LoadError)
	from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

If I run gem install json as root, it fixes that issue, and sunstone can start. Don’t quite understand why. Any idea?

Hello @madko ,

you have a strange version of rubygem-json package. What’s in the base distribution now is 1.7.7 built from ruby source package. See:

# rpm -qi rubygem-json
Name        : rubygem-json
Version     : 1.7.7
Release     : 36.el7
Architecture: x86_64
Install Date: Fri 15 Nov 2019 02:39:32 PM UTC
Group       : Development/Libraries
Size        : 94878
License     : Ruby or GPLv2
Signature   : RSA/SHA256, Thu 22 Aug 2019 09:42:58 PM UTC, Key ID 24c6a8a7f4a80eb5
Source RPM  : ruby-
Build Date  : Thu 08 Aug 2019 12:30:13 PM UTC
Build Host  : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://ruby-lang.org/
Summary     : This is a JSON implementation as a Ruby extension in C

I still can see that your package was built by CentOS guys, but its source is unclear to me (probably some additional SIG repository). Can you please ensure you have updated system and ideally replace (downgrade) the rubygem-json package with the base one?

Also, can you please check the origin of this package (just curious):

# yum info rubygem-json
Installed Packages
Name        : rubygem-json
Arch        : x86_64
Version     : 1.7.7
Release     : 36.el7
Size        : 93 k
Repo        : installed
From repo   : base

Thank you,

My rubygem-json is from official centos-7-opstools repository (we use that for collectd I think), I will try to downgrade to the one from base repo.

So I can confirm that with rubygem-json > 1.7.7 sunstone is not working fine.

I’ve secured this with an excludepkgs=rubygem-json in the centos-7-opstools repo config.

It should be great if opennebula-sunstone really needs a specific version of rubygem-json that this specific version should be mentionned in its RPM requires, don’t you think ? But that’s a big if, it could also be the rubygem-json package from opstools that is broken. Because I guess that the manual gem install json installed the latest version ? Not sure but I think it was a 2.0.2. But after this weekend, the sunstone process was dead. So maybe it really needs 1.7.7 ?

I have already locked version to the base distribution one https://github.com/OpenNebula/packages/commit/4b1fb5163b10269a60780d9270a2ae6585627a24

I’m not very happy about it, but it’s still better than to bundle core gem JSON on our own. BTW, Debian based distributions contain JSON in a core Ruby package (librubyX.Y), so there is not such problem.

The one from OpsTools is a broken at least in a way that it replaces base one, and doesn’t look/behave the same - doesn’t create a symlink.

Thank you,

Thank you for your help Vlastimil, your commit is perfect and should prevent this kind of issue.

Best regards,