无法加载Shorturl宝石(ruby ErrorLoad) [英] Cannot load Shorturl gem (ruby ErrorLoad)

查看:103
本文介绍了无法加载Shorturl宝石(ruby ErrorLoad)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在使用gem install shorturl之后,我们发现,我在项目中添加了以下头文件到一个文件中:

  requirerubygems
requireshorturl

class Controller< Autumn :: Leaf

当我运行该项目时,出现以下错误:


myfile.rb:3在`require'中:不需要加载这样的文件 - shorturl(LoadError)

我不确定其他信息会有用,除非没有脚本运行的要求。我猜我需要将rubygems路径添加到某个变量,但我不知道哪个变量。任何想法?

解决方案

您可以运行 gem environment RubyGems正在运行。在下,GEM PATHS 应该列出RubyGems将搜索gem的路径。



取决于如果你以root用户身份安装了gem,它可能会在 /usr/local/lib/ruby/gems/1.8 或你的主目录中的某个位置。您可以使用 gem list -d shorturl 来找出它的安装位置。如果它不在 GEM PATHS 中列出,您将不得不将它添加到 GEM_PATH 环境变量中。例如:

  exportGEM_PATH = $ GEM_PATH:/usr/local/lib/ruby/gems/1.8

如果这样做,您需要将它添加到像 .bashrc 确保它始终加载。


I'm fairly new to Ruby and keep knocking my head against gems, but this 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.

这篇关于无法加载Shorturl宝石(ruby ErrorLoad)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆