Missing Gem Error in Ruby

1.4k views Asked by At

I'm running a Puppet Installed Sensu Client on Ubuntu 13.04, which in turn executes check-procs.rb.. which fails with:

/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': 
    Could not find json (>= 0) amongst 
    [addressable-2.3.5, amq-client-1.0.2, amq-protocol-1.2.0, amqp-1.0.0, 
    async_sinatra-1.0.0, coffee-script-2.2.0, coffee-script-source-1.6.3, 
    commonjs-0.2.7, cookiejar-0.3.0, daemons-1.1.9, em-http-request-1.0.3, 
    em-redis-unified-0.4.2, em-socksify-0.3.0, em-worker-0.0.2, 
    eventmachine-1.0.3, execjs-2.0.2, handlebars_assets-0.15, hike-1.2.3,
    http_parser.rb-0.6.0, ipaddress-0.8.0, less-2.4.0,
    libv8-3.11.8.17-x86_64-linux, mixlib-cli-1.4.0, mixlib-config-2.1.0,
    mixlib-log-1.6.0, mixlib-shellout-1.3.0, multi_json-1.8.2, ohai-6.16.0,
    oj-2.0.9, rack-1.5.2, rack-protection-1.5.1, ref-1.0.5, sass-3.2.12,
    semver-1.0.1, sensu-0.12.3, sensu-dashboard-0.10.2, sensu-plugin-0.2.2,
    sinatra-1.3.5, slim-2.0.2, sprockets-2.10.1, systemu-2.6.0, systemu-2.5.2,
    temple-0.6.7, therubyracer-0.11.4, thin-1.5.0, tilt-1.4.1, yajl-ruby-1.2.0,
    yui-compressor-0.12.0] (Gem::LoadError) 
        from /usr/lib/ruby/1.9.1/rubygems/specification.rb:777:in `block in activate_dependencies'
        from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each' 
        from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies' from /usr/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate' from /usr/lib/ruby/1.9.1/rubygems.rb:212:in `rescue in try_activate' 
        from /usr/lib/ruby/1.9.1/rubygems.rb:209:in `try_activate' 
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require' from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require' 
        from /etc/sensu/plugins/check-procs.rb:29:in `<main>' 

The strange thing is that it works fine on CentOS 6.4. On both servers the sensu client is installed via official packages, via APT and/or YUM as appropriate.

I can kinda see the problem, I just don't know what it means or how to fix it.

CentOS Tests

[root@centos-vm]# gem list

*** LOCAL GEMS ***

json (1.5.5)
semver (1.0.1)

[root@centos-vm]# ls -l /usr/lib/ruby/gems/1.8/gems/
total 8
drwxr-xr-x. 5 root root 4096 Jan  8 04:46 json-1.5.5
drwxr-xr-x. 4 root root 4096 Jan  8 04:51 semver-1.0.1

Ubuntu Tests

[root@ubuntu-vm]# gem list

*** LOCAL GEMS ***

semver (1.0.1)

[root@ubuntu-vm]# ls -l /var/lib/gems/1.9.1/gems
total 8
drwxr-xr-x 9 root root 4096 Jan  8 10:03 json-1.8.1
drwxr-xr-x 4 root root 4096 Jan  8 04:59 semver-1.0.1

It's there, but not in the GEM list. Notice also that 'semver' is included in the 'amongst' list of the error.

[root@ubuntu-vm]# ls -l /var/lib/gems/1.9.1/gems/json-1.8.1/
total 140
-rw-rw-r-- 1 root root 15043 Jan  8 10:03 CHANGES
-rw-rw-r-- 1 root root  2574 Jan  8 10:03 COPYING
-rw-rw-r-- 1 root root  2591 Jan  8 10:03 COPYING-json-jruby
drwxr-xr-x 2 root root  4096 Jan  8 10:03 data
drwxr-xr-x 2 root root  4096 Jan  8 10:03 diagrams
drwxr-xr-x 3 root root  4096 Jan  8 10:03 ext
-rw-rw-r-- 1 root root   200 Jan  8 10:03 Gemfile
-rw-rw-r-- 1 root root 18114 Jan  8 10:03 GPL
-rwxrwxr-x 1 root root   441 Jan  8 10:03 install.rb
drwxr-xr-x 3 root root  4096 Jan  8 10:03 java
-rw-rw-r-- 1 root root  4869 Jan  8 10:03 json.gemspec
-rw-rw-r-- 1 root root   549 Jan  8 10:03 json-java.gemspec
-rw-rw-r-- 1 root root  4929 Jan  8 10:03 json_pure.gemspec
drwxr-xr-x 3 root root  4096 Jan  8 10:03 lib
-rw-rw-r-- 1 root root 11995 Jan  8 10:03 Rakefile
-rw-rw-r-- 1 root root   929 Jan  8 10:03 README-json-jruby.markdown
-rw-rw-r-- 1 root root 12561 Jan  8 10:03 README.rdoc
drwxr-xr-x 3 root root  4096 Jan  8 10:03 tests
-rw-rw-r-- 1 root root     1 Jan  8 10:03 TODO
drwxr-xr-x 2 root root  4096 Jan  8 10:03 tools
-rw-rw-r-- 1 root root     6 Jan  8 10:03 VERSION

In case it matters, Sensu also has an 'embedded Ruby', which contains a collection of gems as well. Both servers seem to be virtually identical in this regard..

[root@either-vm]# ls -l /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/
total 200
drwxr-xr-x 7 root root 4096 Jan  8 05:00 addressable-2.3.5
drwxr-xr-x 6 root root 4096 Jan  8 05:00 amq-client-1.0.2
drwxr-xr-x 7 root root 4096 Jan  8 05:00 amqp-1.0.0

..... lots more .....

Any help would be appreciated! Thanks.

1

There are 1 answers

0
JoshZ On

Is sensu using the default ruby to run or is it using sensu's embedded ruby? My default chef installations use /opt/sensu/embedded/bin/ruby to run and thus all of my check commands are /opt/sensu/embedded/bin/ruby check_procs.rb etc...

I think this is better anyhow because it keeps your system ruby (if installed) clean and keeps sensu only on sensu's embedded ruby.