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?
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.
On Fri, 2007-11-09 at 04:59 +0900, Peter H. wrote:
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.
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
require ‘rubygems’
require ‘json’
works for me!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.