开发者

Cannot load Shorturl gem (ruby ErrorLoad)

I'm fairly new to Ruby and keep knocking my head against gems, but thi开发者_如何学运维s latest puzzle has really got me stumped.

After using the gem install shorturl, I added the following headers to a file in my project:

require "rubygems"
require "shorturl"

class Controller < Autumn::Leaf

When I run the project I get the following error:

myfile.rb:3 in `require': no such file to load -- shorturl (LoadError)

I'm not sure what other information would be useful, except that without the require the script is working. I'm guessing I need to add the rubygems path to some variable, but I have no idea which. Any ideas?


You can run gem environment to see the environment that RubyGems is running in. Under GEM PATHS should be listed the paths that RubyGems will search for gems.

Depending on if you installed the gem as root or not it will either be under somewhere like /usr/local/lib/ruby/gems/1.8 or somewhere within your home directory. You can use gem list -d shorturl to find out where it is installed. If where it is isn't listed in the GEM PATHS you will have to add it to the GEM_PATH environment variable. For example:

export "GEM_PATH=$GEM_PATH:/usr/local/lib/ruby/gems/1.8"

if that works you then need to add it to somewhere like your .bashrc to ensure its always loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜