尽管已安装 gem,但无法找到 gem [英] gem which cannot find gem despite it being installed
问题描述
我已经构建了我的第一个 gem,但我似乎无法正确安装它.我可以发出命令
I've built my first gem but I don't seem to be able to get it to install correctly. I can issue the command
sudo gem install ceilingfish-toto
哪个产生输出
Successfully installed ceilingfish-toto-0.3.6
1 gem installed
但是当我输入 gem which ceilingfish-toto
时.我得到了输出
But when I then type gem which ceilingfish-toto
. I get the output
Can't find ruby library file or shared library ceilingfish-toto
这很奇怪,因为如果我去查看我的 gems 文件夹,我可以看到那里安装的所有文件
Which is very strange because if I go and look in my gems folder I can see all the files installed there
# ls -l /opt/local/lib/ruby/gems/1.8/gems/ceilingfish-toto-0.3.6/
total 48
-rw-r--r-- 1 root admin 1053 14 Feb 17:16 LICENSE
-rw-r--r-- 1 root admin 6166 14 Feb 17:16 README.md
-rw-r--r-- 1 root admin 879 14 Feb 17:16 Rakefile
-rw-r--r-- 1 root admin 6 14 Feb 17:16 VERSION
-rw-r--r-- 1 root admin 2477 14 Feb 17:16 ceilingfish-toto.gemspec
drwxr-xr-x 7 root admin 238 14 Feb 17:16 test
有人知道是什么原因造成的吗?我认为这是在抱怨,因为 gem 名称中有一个连字符.您可以在此处查看 gemspec http://github.com/ceilingfish/toto
Does anyone know what could cause this? I think it's complaining because there is a hyphen in the gem name. You can see the gemspec here http://github.com/ceilingfish/toto
推荐答案
ceilingfish-toto 的gem
通过gem 查找名为ceilingfish-toto.rb 的文件的路径.由于没有一个,它什么也不返回.对您有用的是 gem which toto
,但由于 lib/
不包含在您的 gem 规范中,因此未安装 lib 文件,因此它不存在.
gem which ceilingfish-toto
looks through the gem require path for a file named ceilingfish-toto.rb. Since there isn't one, it returns nothing. What would work for you is gem which toto
, but since lib/
is not included in your gem spec, the lib files are not installed, so it doesn't exist.
重新运行 rake gemspec
可能会解决问题.
Rerunning rake gemspec
might fix the problem.
顺便说一句,您可以使用 gem list ceilingfish-toto
来检查 gem 是否按其名称安装,这应该显示它已安装,无论它有什么文件(它也会列出安装的版本).
As an aside, you can check whether a gem is installed by its name by using gem list ceilingfish-toto
which should show you it is installed, regardless of the files it has(it will also list the versions installed).
这篇关于尽管已安装 gem,但无法找到 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!