RubyGems Sporadic Weirdness

I’ve been chasing my tail on this problem for a couple days now and its
further away than ever. I am running a Rails 3.1, Ruby

1.9, Gem 1.8.15, Linux RHEL 4 environment.

The simplified problem is that ruby ‘require’ (and rails) can’t find all
the gems my app needs. And it seems that the gems require can’t find
have a gem name different than the *.rb. For example, “require ‘sass’”
locates sass.rb. But “require ‘therubyracer’” fails to locate the v8.rb
inside the lib. There is no file called ‘therubyracer.rb’. Same with
‘therubyrhino’ -
there is no’therubyrhino.rb’ but there is a ‘rhino.rb’ in the lib.

Bundle install does not throw an error even when these gems are in my
Gemfile.

Here is an example:

First, to demonstrate the gem is installed:

locate ‘rhino.rb’
/usr/local/lib/ruby/gems/1.9.1/gems/therubyrhino-1.73.1/lib/rhino.rb
/usr/local/lib/ruby/gems/1.9.1/gems/gems/therubyrhino-1.73.1/lib/rhino.rb

Even though ‘therubyrhino’ is installed, and in the path, and bundle
worked, ‘gem which’ cannot find it. And this gem is in the

same path as ‘sass’, below, which it can find. Here is the error:

gem which ‘therubyrhino’
ERROR: Can’t find ruby library file or shared library therubyrhino

Note that gem can find the rhino.rb file inside the gem, so the path
must be working.

gem which rhino
/usr/local/lib/ruby/gems/1.9.1/gems/therubyrhino-1.73.1/lib/rhino.rb

Require doesn’t like the rhino.rb though:

ruby -rubygems -e ‘require “rhino”’
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`
require’: no such file to load – java (LoadError)

And it can’t find the gem by name.

ruby -rubygems -e ‘require “therubyrhino”’
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require': no such file to load -- therubyrhino (LoadError) from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require’

But as I mentioned, whith ‘therubyrhino’ in my Gemfile, Bundle install
works.

Here is my gem path, which I am setting manually to test:

export
GEM_PATH=/usr/local/lib/ruby/gems/1.9.1:/usr/local/lib/ruby/gems/1.9.1/gems:/usr/local/lib/ruby/gems/1.9.1/gems/gem

gem env

RubyGems Environment:

  • RUBYGEMS VERSION: 1.8.15
  • RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i686-linux]
  • INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
  • RUBY EXECUTABLE: /usr/local/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/local/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86-linux
  • GEM PATHS:
    • /usr/local/lib/ruby/gems/1.9.1
    • /usr/local/lib/ruby/gems/1.9.1/gems
    • /usr/local/lib/ruby/gems/1.9.1/gems/gem
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

And finally, here is a case where life is good and require works. All is
well and the prefix of the gem name = lib name

(…/sass/lib/sass.rb). First we can see that the sass gem is installed:

locate sass.rb
/usr/local/lib/ruby/gems/1.9.1/gems/sass-3.1.14/lib/sass.rb
/usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/vendor/sass/lib/sass.rb
/usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/lib/sass.rb

Can Gem find it? Yes.

gem which sass
/usr/local/lib/ruby/gems/1.9.1/gems/haml-3.1.4/lib/sass.rb

And does ruby ‘require’ work? Yes.

ruby -rubygems -e ‘require “sass”’
(no error)

therubyrhino is only useful when running jruby. You mentioned
therubyracer,
what happens when you try to require that?

pete

On Thu, Feb 9, 2012 at 9:07 PM, Pete H. [email protected]
wrote:

therubyrhino is only useful when running jruby. You mentioned
therubyracer, what happens when you try to require that?

pete

Sorry, I hit send accidentally while revising. What I meant to say is
that
therubyrhino requires jruby. Check out the requirements section in the
Readme: https://github.com/cowboyd/therubyrhino

pete

On Feb 9, 2012, at 18:51 , Steve Johnston wrote:

/usr/local/lib/ruby/gems/1.9.1/gems/therubyrhino-1.73.1/lib/rhino.rb
/usr/local/lib/ruby/gems/1.9.1/gems/gems/therubyrhino-1.73.1/lib/rhino.rb

Pete’s suggestion still stands, but this stands out and needs some
attention.

I’m guessing that at some point you messed up an ENV var and set
GEM_HOME to:

/usr/local/lib/ruby/gems/1.9.1/gems/

when it should be:

/usr/local/lib/ruby/gems/1.9.1/

and then re-installed therubyrhino. “/gems/” will be appended to your
GEM_HOME and that’s why you have a directory with “/gems/gems/” in it.

I’ll go a step further and say that if your ruby in installed “properly”
(aka, whatever way is usual on your system), don’t set GEM_HOME at all,
unless you have a damn good reason to. Rubygems will pick up the correct
gem repo on its own.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs