Forum: Ruby some gems not working anymore

Posted by johnny mo (johnny1941)
on 2012-11-19 21:55
hi,

I have a very strange issue. Some of my installed gems are not working
anymore. For example:

$ ruby -rrack/test -e 1
/home/jacky/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file -- rack/test (LoadError)
  from
/home/jacky/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'


Which is strange because:

$ gem which rack/test
/home/jacky/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/test.rb

So clearly the gem executable can see the gem, but ruby cannot. This is
not the only gem not working anymore, but some gems do work. I tried
reinstalling to no avail. File permissions look OK. Ruby version is
1.9.3 (under rvm as you can see above) and gem is 1.8.24. OS is Ubuntu
10.04.

Any ideas on how to resolve this?
Posted by Grant Schoep (matobinder)
on 2012-11-20 02:36
Odd, I'd verify your using the same gem that came with your build of 
ruby.

i.e. run these commands
which gem
which ruby

Make sure there from the same install(nominally that would be the same 
directory). You could be grabbing a ruby install from something else, 
and a gem binary a different source
Posted by johnny mo (johnny1941)
on 2012-11-20 10:02
hi,

Thanks for looking into this.

$ which ruby
/home/jacky/.rvm/bin/ruby
$ which gem
/usr/bin/gem
$ ls -l /usr/bin/gem
/usr/bin/gem -> /home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/gem

So I changed the softlink /usr/bin/gem to point to
/home/jacky/.rvm/bin/gem
Unfortunately, the problem stayed the same. But that's not surprising
given that the content of /home/jacky/.rvm/bin/gem is:
#!/usr/bin/env bash

if [[ -s "/home/jacky/.rvm/environments/ruby-1.9.3-p194" ]]
then
  source "/home/jacky/.rvm/environments/ruby-1.9.3-p194"
  exec gem "$@"
else
  echo "ERROR: Missing RVM environment file:
'/home/jacky/.rvm/environments/ruby-1.9.3-p194'" >&2
  exit 1
fi

Any other ideas?
Posted by Robert Klemme (robert_k78)
on 2012-11-20 10:18
(Received via mailing list)
On Tue, Nov 20, 2012 at 10:02 AM, johnny mo <lists@ruby-forum.com> 
wrote:
> hi,
>
> Thanks for looking into this.
>
> $ which ruby
> /home/jacky/.rvm/bin/ruby
> $ which gem
> /usr/bin/gem

This looks suspicious: why do you have a /usr/bin/gem but not a 
/usr/bin/ruby?

> $ ls -l /usr/bin/gem
> /usr/bin/gem -> /home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/gem
>
> So I changed the softlink /usr/bin/gem to point to
> /home/jacky/.rvm/bin/gem

I'd probably rather remove /usr/bin/gem completely.  Somehow you seem
to be mixing installations.  What OS and distribution is this and what
did you do to install ruby?

Cheers

robert
Posted by johnny mo (johnny1941)
on 2012-11-20 10:23
This is Ubuntu 10.04.

What happened was that I installed ruby 1.8.7 a long time ago. After a
few months I installed rvm (which was previously missing) and ruby 1.9.3
and subsequently removed 1.8.7. That's why /usr/bin/gem exists. I've now
removed it. No change to the situation though.
Posted by Robert Klemme (robert_k78)
on 2012-11-20 11:19
(Received via mailing list)
On Tue, Nov 20, 2012 at 10:23 AM, johnny mo <lists@ruby-forum.com> 
wrote:
> This is Ubuntu 10.04.
>
> What happened was that I installed ruby 1.8.7 a long time ago. After a
> few months I installed rvm (which was previously missing) and ruby 1.9.3
> and subsequently removed 1.8.7. That's why /usr/bin/gem exists. I've now
> removed it. No change to the situation though.

Hm.... Did you check "gem environment"?

Cheers

robert
Posted by johnny mo (johnny1941)
on 2012-11-20 11:24
I think you got it!

$ which ruby
/home/jacky/.rvm/bin/ruby

$gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i686-linux]
  - INSTALLATION DIRECTORY: /home/jacky/.rvm/gems/ruby-1.9.3-p194
  - RUBY EXECUTABLE: /home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /home/jacky/.rvm/gems/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/jacky/.rvm/gems/ruby-1.9.3-p194
     - /home/jacky/.rvm/gems/ruby-1.9.3-p194@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/


Now the question is which ruby executable should I choose and what would
be the best way of pointing the system to it?
Posted by Robert Klemme (robert_k78)
on 2012-11-20 11:36
(Received via mailing list)
On Tue, Nov 20, 2012 at 11:24 AM, johnny mo <lists@ruby-forum.com> 
wrote:
>   - RUBY EXECUTABLE: /home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
>      - :benchmark => false
>      - :backtrace => false
>      - :bulk_threshold => 1000
>   - REMOTE SOURCES:
>      - http://rubygems.org/
>
>
> Now the question is which ruby executable should I choose and what would
> be the best way of pointing the system to it?

That should be decided by rvm.  Maybe you need to reinstall now that
you removed the remainders of the old installation.

Kind regards

robert
Posted by johnny mo (johnny1941)
on 2012-11-20 11:41
But something's strange, they're both exactly the same:

$/home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
jacky@jacky:~$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
Posted by Robert Klemme (robert_k78)
on 2012-11-20 12:26
(Received via mailing list)
On Tue, Nov 20, 2012 at 11:41 AM, johnny mo <lists@ruby-forum.com> 
wrote:
> But something's strange, they're both exactly the same:
>
> $/home/jacky/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -v
> ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
> jacky@jacky:~$ ruby -v
> ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]

Did you reinstall?  Does the original error still show?

Cheers

robert
Posted by johnny mo (johnny1941)
on 2012-11-20 14:04
Aha! You're right, reinstalling rvm helped. Thanks very much for your 
help Robert.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.