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?
Datum: Thu, 8 Nov 2007 16:33:25 +0900
Von: Peter Hug <pete@kapiti.co.nz>
An: ruby-talk@ruby-lang.org
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?
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?
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.
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?
Your Windows installation probably automagically includes the gem path
in Ruby's search path (perhaps the installation you have includes some
gems, and so puts that in for you).
You can see what paths are included in the search. You should always
require 'rubygems' before requiring anything you expect may be in a gem,
though, for maximum cross-compatibility.
Pete
Cheers,
Arlen
···
On Fri, 2007-11-09 at 04:59 +0900, Peter Hug wrote:
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
···
On Nov 8, 2007 2:59 PM, Peter Hug <pete@kapiti.co.nz> 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.