Problem with gems (require not working)


T

Tomas Korcak

Hi there,
somehow my rubygems got cripled. The problem is ruby/irb is not able to
find/locate any of my previously installed gems. The problem is that
when I install some gem I am not able to use it (require could not
locate that gem). You can see bash output below. I tried to
remove/purge/autoremove/install ruby/rubygems/irb many times and still
it is not working. Thank you for any ideas provided in advance.

Platform:
[email protected]:~/prog/smartdata/bin$ uname -a
Linux korczis-nb 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 09:00:03
UTC 2010 i686 GNU/Linux

[email protected]:~/prog/smartdata/bin$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]

[email protected]:~/prog/smartdata/bin$ gem -v
1.3.5

Let me show you that:
1) I will install nokogiri gem
[email protected]:~/prog/smartdata/bin$ sudo gem install nokogiri
Building native extensions. This could take a while...
Successfully installed nokogiri-1.4.4
1 gem installed
Installing ri documentation for nokogiri-1.4.4...
No definition for get_options
No definition for set_options
No definition for parse_memory
No definition for parse_file
No definition for parse_with
Installing RDoc documentation for nokogiri-1.4.4...
No definition for get_options
No definition for set_options
No definition for parse_memory
No definition for parse_file
No definition for parse_with
[email protected]:~/prog/smartdata/bin$

2) I will try to check it with irb (You will see that irb is not able to
locate previously installed gem)
[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> require 'nokogiri'
LoadError: no such file to load -- nokogiri
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0>


3) I will list installed gems
[email protected]:~/prog/smartdata/bin$ gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.3, 2.3.8)
actionpack (3.0.3, 2.3.8)
activemodel (3.0.3)
activerecord (3.0.3, 2.3.8)
activeresource (3.0.3, 2.3.8)
activesupport (3.0.3, 2.3.8)
arel (2.0.6)
builder (3.0.0, 2.1.2)
cgi_multipart_eof_fix (2.5.0)
chunky_png (0.12.0)
daemons (1.1.0)
erubis (2.6.6)
eventmachine (0.12.10)
fastthread (1.0.7)
gem_plugin (0.2.3)
i18n (0.5.0)
jrails (0.6.0)
mail (2.2.12)
markaby (0.7.1)
mime-types (1.16)
mongrel (1.1.5)
nokogiri (1.4.4)
pg (0.10.0)
polyglot (0.3.1)
postgres (0.7.9.2008.01.28)
postgres-pr (0.6.3)
rack (1.2.1, 1.1.0)
rack-mount (0.6.13)
rack-test (0.5.6)
rake (0.8.7)
treetop (1.4.9)
tzinfo (0.3.23)
[email protected]:~/prog/smartdata/bin$
 
Ad

Advertisements

H

Hassan Schroeder

Hi there,
somehow my rubygems got cripled. The problem is ruby/irb is not able to
find/locate any of my previously installed gems.
2) I will try to check it with irb (You will see that irb is not able to
locate previously installed gem)
[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> require 'nokogiri'
LoadError: no such file to load -- nokogiri

OK, so what does

irb> puts $:

tell you?
 
T

Tomas Korcak

Hassan Schroeder wrote in post #970159:
OK, so what does

irb> puts $:

tell you?

Ugh, something is cripled probably...

[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> puts $:
/usr/local/lib/site_ruby/1.8
/usr/local/lib/site_ruby/1.8/i486-linux
/usr/local/lib/site_ruby/1.8/i386-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i486-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i486-linux
/usr/lib/ruby/1.8/i386-linux
 
T

Tomas Korcak

[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> puts $:
/usr/local/lib/site_ruby/1.8
/usr/local/lib/site_ruby/1.8/i486-linux
/usr/local/lib/site_ruby/1.8/i386-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/1.8
/usr/lib/ruby/vendor_ruby/1.8/i486-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i486-linux
/usr/lib/ruby/1.8/i386-linux
.
=> nil
irb(main):002:0> puts $
SyntaxError: compile error
(irb):2: syntax error, unexpected $undefined, expecting $end
from (irb):2
from :0
irb(main):003:0>

Am I right when I am thinking that it is looking for gems somewhere else
that it should be (/usr/local/lib/site_ruby/1.8)?

PS: Maybe I did installed ruby from sources in past and there is some
residue causing the problem at the moment.. I am not sure
 
R

Ryan Davis

2) I will try to check it with irb (You will see that irb is not able = to
locate previously installed gem)
[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> require 'nokogiri'
LoadError: no such file to load -- nokogiri

You need to 'require "rubygems"' in ruby 1.8. If your ~/.irbrc doesn't =
have that, you must do it explicitly when you fire up irb.
 
P

Phillip Gawlowski

Am I right when I am thinking that it is looking for gems somewhere else
that it should be (/usr/local/lib/site_ruby/1.8)?

PS: Maybe I did installed ruby from sources in past and there is some
residue causing the problem at the moment.. I am not sure

What does

require "rubygems"
require "nokogiri"

output in irb?

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
Ad

Advertisements

T

Tomas Korcak

You need to 'require "rubygems"' in ruby 1.8. If your ~/.irbrc doesn't
have that, you must do it explicitly when you fire up irb.

Wow, amazing, it is working as the sharm.. Thank you for that point
Ryan.

Everybody excuse me please for that kind of silly question. That had to
be questioned many times before but I was not able to google for any
solution :(

Last quick question. How can I setup ~/.irbrc to do not need include
rubygems in every (irb instance)/(ruby file) manualy?

[email protected]:~/prog/smartdata/bin$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'nokogiri'
=> true
irb(main):003:0> require 'png'
LoadError: no such file to load -- inline
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /var/lib/gems/1.8/gems/png-1.2.0/lib/png.rb:5
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):3
from :0
irb(main):004:0> exit
[email protected]:~/prog/smartdata/bin$

PS: There is still some problem with png library but that will be some
png lib issue (i think).
 
T

Tomas Korcak

Thanks Everybody (especially Phillip, Hassan and Ryan) for incredibly
fast reply. Problem is solved now. It was sufficient to just include
ruby gems explicitly or to put "require 'rubygems'" line in ~/.irbrc
file.

PS: I am surprised in good way again how friendly ruby community is..

Thanks for help, have a happy christmas,
Tomas
 
Ad

Advertisements

R

Ryan Davis

irb(main):003:0> require 'png'
LoadError: no such file to load -- inline
...
PS: There is still some problem with png library but that will be some
png lib issue (i think).

For some reason you have the png gem installed but not the RubyInline gem.

sudo gem install RubyInline

should fix that. There is no dependency on libpng.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top