LoadError: no such file to load

Discussion in 'Ruby' started by Peter Hug, Nov 8, 2007.

  1. Peter Hug

    Peter Hug Guest

    This happens on a i486 Ubuntu 7.04 machine. If I do:

    gem list --local

    I get a list of installed gems. However, if I then try to load any of
    these gems like for example the (json gem) as follows:

    require 'json'

    I get a LoadError: no such file to load. I have worked out where for
    example the json gem resides and then I navigated to that directory and
    used irb to test if require 'json' would work from there and it seemed
    fine (returned true).

    It appears to me that ruby doesn't know the path to gems, how can I fix
    this?

    Pete
    --
    Posted via http://www.ruby-forum.com/.
     
    Peter Hug, Nov 8, 2007
    #1
    1. Advertising

  2. Peter Hug

    Axel Etzold Guest

    -------- Original-Nachricht --------
    > Datum: Thu, 8 Nov 2007 16:33:25 +0900
    > Von: Peter Hug <>
    > An:
    > Betreff: LoadError: no such file to load


    > This happens on a i486 Ubuntu 7.04 machine. If I do:
    >
    > gem list --local
    >
    > I get a list of installed gems. However, if I then try to load any of
    > these gems like for example the (json gem) as follows:
    >
    > require 'json'
    >
    > I get a LoadError: no such file to load. I have worked out where for
    > example the json gem resides and then I navigated to that directory and
    > used irb to test if require 'json' would work from there and it seemed
    > fine (returned true).
    >
    > It appears to me that ruby doesn't know the path to gems, how can I fix
    > this?
    >
    > Pete
    > --
    > Posted via http://www.ruby-forum.com/.



    Dear Pete,

    try

    require "rubygems"
    require "json"

    This should work.

    Best regards,

    Axel
    --
    Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
    Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
     
    Axel Etzold, Nov 8, 2007
    #2
    1. Advertising

  3. Peter Hug

    Peter Hug Guest

    Axel Etzold wrote:
    > require "rubygems"
    > require "json"


    Spot on Axel, that fixed it! Thanks heaps.

    What puzzles me though is that the same setup works fine under Windows
    (i.e. my ruby scripts can use any installed gems without having to load
    rubygems first.

    Any idea why that would be?

    Pete
    --
    Posted via http://www.ruby-forum.com/.
     
    Peter Hug, Nov 8, 2007
    #3
  4. Peter Hug

    Alex LeDonne Guest

    On Nov 8, 2007 2:59 PM, Peter Hug <> wrote:
    > Axel Etzold wrote:
    > > require "rubygems"
    > > require "json"

    >
    > Spot on Axel, that fixed it! Thanks heaps.
    >
    > What puzzles me though is that the same setup works fine under Windows
    > (i.e. my ruby scripts can use any installed gems without having to load
    > rubygems first.
    >
    > Any idea why that would be?
    >
    >
    > Pete


    The Ruby One-Click Installer sets an environment variable calld
    RUBYOPT to -rubygems, which causes ruby to automatically require
    'rubygems' for you.

    You could set RUBYOPT on your Ubuntu box, if you like.

    -A
     
    Alex LeDonne, Nov 9, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruby Ruby
    Replies:
    0
    Views:
    191
    Ruby Ruby
    Apr 22, 2004
  2. Brian Takita
    Replies:
    7
    Views:
    320
    Brian Takita
    May 24, 2005
  3. Zoong Pham
    Replies:
    1
    Views:
    284
    Chad Fowler
    Aug 11, 2005
  4. Replies:
    1
    Views:
    334
    Eric Hodel
    Oct 25, 2005
  5. anne001
    Replies:
    4
    Views:
    141
    Jaypee
    Nov 16, 2005
Loading...

Share This Page