Problem with require 'gemname'

Howdy folks,

Requiring gems doesn’t work unless I use gem ‘gemname’ before require
‘gemname’. Any idea why?

Here is an example:

gem list

*** LOCAL GEMS ***

abstract (1.0.0)
.
.
.
nokogiri (1.4.1)
.
.
.

irb

irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require ‘nokogiri’
LoadError: no such file to load – nokogiri
from (irb):2:in require' from (irb):2 from /usr/bin/irb:12:in
irb(main):003:0> gem ‘nokogiri’
=> true
irb(main):004:0> require ‘nokogiri’
=> true

Keith C. wrote:

Howdy folks,

Requiring gems doesn’t work unless I use gem ‘gemname’ before require
‘gemname’. Any idea why?

any recent upgrades? which version of gems/ruby?
-rp

Keith C. wrote:

Ruby 1.9.1 and gems 1.3.6.

Hmm works ok for me. Make sure that $: includes
…/nokogiri-version/lib and it should work.
Sorry I can’t be of more help.
-rp

Ruby 1.9.1 and gems 1.3.6.

Maybe I need to change the gem paths somehow? Looks like it is pointing
to the right place though, see the ls below.

gem env

RubyGems Environment:

  • RUBYGEMS VERSION: 1.3.6
  • RUBY VERSION: 1.9.1 (2009-07-16 patchlevel 243) [x86_64-linux]
  • INSTALLATION DIRECTORY: /usr/lib/ruby1.9.1/gems/1.9.1
  • RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • x86_64-linux
  • GEM PATHS:
    • /usr/lib/ruby1.9.1/gems/1.9.1
    • /root/.gem/ruby/1.9.1
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:

ls /usr/lib/ruby1.9.1/gems/1.9.1/gems/

abstract-1.0.0 activesupport-2.3.5 nokogiri-1.4.1
rails-3.0.0.beta3
actionmailer-2.3.5 activesupport-3.0.0.beta3 pg-0.9.0
railties-3.0.0.beta3
actionmailer-3.0.0.beta3 arel-0.3.3 polyglot-0.3.1
rake-0.8.7
actionpack-2.3.5 builder-2.1.2
postgres-0.7.9.2008.01.28 text-format-1.0.0
actionpack-3.0.0.beta3 bundler-0.9.24 postgres-pr-0.6.3
text-hyphen-1.0.0
activemodel-3.0.0.beta3 erubis-2.6.5 rack-1.0.1
thor-0.13.4
activerecord-2.3.5 i18n-0.3.7 rack-1.1.0
treetop-1.4.5
activerecord-3.0.0.beta3 mail-2.2.0 rack-mount-0.6.3
tzinfo-0.3.20
activeresource-2.3.5 memcache-client-1.8.2 rack-test-0.5.3
activeresource-3.0.0.beta3 mime-types-1.16 rails-2.3.5

Roger P. wrote:

Make sure that $: includes
…/nokogiri-version/lib and it should work.

I’m not sure what that means, but none of the gems work, it’s not just
nokogiri.

Keith C. wrote:

Roger P. wrote:

Make sure that $: includes
…/nokogiri-version/lib and it should work.

I’m not sure what that means, but none of the gems work, it’s not just
nokogiri.

doing

p $:

should include the lib dirs mentioned.

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