LoadError: no such file to load

P

Peter Hug

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
 
A

Axel Etzold

-------- Original-Nachricht --------
Datum: Thu, 8 Nov 2007 16:33:25 +0900
Von: Peter Hug <[email protected]>
An: (e-mail address removed)
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


Dear Pete,

try

require "rubygems"
require "json"

This should work.

Best regards,

Axel
 
P

Peter Hug

Axel said:
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
 
A

Alex LeDonne

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
 

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

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top