宝石虽然安装了但却找不到宝石

时间:2022-12-03 22:42:39

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

Which produces the output

哪个产生输出

Successfully installed ceilingfish-toto-0.3.6
1 gem installed

But when I then type gem which ceilingfish-toto. I get the output

但是当我输入gemfish-toto时。我得到了输出

Can't find ruby library file or shared library ceilingfish-toto

Which is very strange because if I go and look in my gems folder I can see all the files installed there

这很奇怪,因为如果我去查看我的gems文件夹,我可以看到安装在那里的所有文件

# 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

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

有谁知道这会导致什么?我认为这是抱怨,因为宝石名称中有一个连字符。你可以在http://github.com/ceilingfish/toto看到gemspec

3 个解决方案

#1


6  

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.

ceilingfish-toto通过gem查找的gem需要一个名为ceilingfish-toto.rb的文件的路径。由于没有一个,它什么都不返回。什么对你有用的是gem,但是由于lib /未包含在你的gem规范中,所以lib文件没有安装,所以它不存在。

Rerunning rake gemspec might fix the problem.

重新运行rake gemspec可能会解决问题。

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 list ceilingfish-toto检查gem是否按其名称安装,它应该显示它已安装,无论它有什么文件(它还会列出已安装的版本)。

#2


7  

It's not the hyphen.

这不是连字符。

gem which searches for library files in gems, not gems. Compare:

gem在宝石中搜索库文件,而不是宝石。相比:

$ gem which haml
/home/dave/.gem/ruby/1.8/gems/haml-3.0.12/lib/haml.rb
$ ls haml-3.0.12/lib/h*
haml  haml.rb  haml.rbc

Peachy. Note the existance of lib/haml.rb.

桃色的。注意lib / haml.rb的存在。

$ gem which rails
ERROR:  Can't find ruby library file or shared library rails
$ ls rails-2.3.8/lib/r*
rails_generator.rb  railties_path.rb  rubyprof_ext.rb  ruby_version_check.rb

There is no lib/rails.rb. But try:

没有lib / rails.rb。但试试:

$ gem which railties_path # not a gem
/home/dave/.gem/ruby/1.8/gems/rails-2.3.8/lib/railties_path.rb

So gem which ceilingfish-toto throws an error even when ceilingfish-toto is installed because there is no lib/ceilingfish-toto.rb file (there's not even a lib folder).

所以即使安装了ceilingfish-toto,由于没有lib / ceilingfish-toto.rb文件(甚至没有lib文件夹),天花板-toto也会抛出错误。

#3


-1  

OK, so the problem here appears to be that there was a problem with my gemspec file. From what I can tell there absolutely has to be a file with the name lib/gem-name.rb so in this case I needed lib/ceilingfish-toto.rb.

好的,所以这里的问题似乎是我的gemspec文件有问题。从我所知道的,绝对必须是一个名为lib / gem-name.rb的文件,所以在这种情况下我需要lib / ceilingfish-toto.rb。

This doesn't seem to be true for some other gems to operate correctly. For example mime-types or rest-client, even though they do not show up with gem which, they do actually work.

对于其他一些宝石来说,这似乎并不正确。例如mime-types或rest-client,即使它们没有显示gem,它们确实可以工作。

I'm not sure this is entirely correct yet, I'm sure there should be a way to get a gem with a hyphen in the name to behave correctly. If I find out I'll post back and let y'all know.

我不确定这是否完全正确,我确信应该有一种方法可以在名称中使用带有连字符的宝石来正确运行。如果我发现我会回复并让你们都知道。

#1


6  

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.

ceilingfish-toto通过gem查找的gem需要一个名为ceilingfish-toto.rb的文件的路径。由于没有一个,它什么都不返回。什么对你有用的是gem,但是由于lib /未包含在你的gem规范中,所以lib文件没有安装,所以它不存在。

Rerunning rake gemspec might fix the problem.

重新运行rake gemspec可能会解决问题。

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 list ceilingfish-toto检查gem是否按其名称安装,它应该显示它已安装,无论它有什么文件(它还会列出已安装的版本)。

#2


7  

It's not the hyphen.

这不是连字符。

gem which searches for library files in gems, not gems. Compare:

gem在宝石中搜索库文件,而不是宝石。相比:

$ gem which haml
/home/dave/.gem/ruby/1.8/gems/haml-3.0.12/lib/haml.rb
$ ls haml-3.0.12/lib/h*
haml  haml.rb  haml.rbc

Peachy. Note the existance of lib/haml.rb.

桃色的。注意lib / haml.rb的存在。

$ gem which rails
ERROR:  Can't find ruby library file or shared library rails
$ ls rails-2.3.8/lib/r*
rails_generator.rb  railties_path.rb  rubyprof_ext.rb  ruby_version_check.rb

There is no lib/rails.rb. But try:

没有lib / rails.rb。但试试:

$ gem which railties_path # not a gem
/home/dave/.gem/ruby/1.8/gems/rails-2.3.8/lib/railties_path.rb

So gem which ceilingfish-toto throws an error even when ceilingfish-toto is installed because there is no lib/ceilingfish-toto.rb file (there's not even a lib folder).

所以即使安装了ceilingfish-toto,由于没有lib / ceilingfish-toto.rb文件(甚至没有lib文件夹),天花板-toto也会抛出错误。

#3


-1  

OK, so the problem here appears to be that there was a problem with my gemspec file. From what I can tell there absolutely has to be a file with the name lib/gem-name.rb so in this case I needed lib/ceilingfish-toto.rb.

好的,所以这里的问题似乎是我的gemspec文件有问题。从我所知道的,绝对必须是一个名为lib / gem-name.rb的文件,所以在这种情况下我需要lib / ceilingfish-toto.rb。

This doesn't seem to be true for some other gems to operate correctly. For example mime-types or rest-client, even though they do not show up with gem which, they do actually work.

对于其他一些宝石来说,这似乎并不正确。例如mime-types或rest-client,即使它们没有显示gem,它们确实可以工作。

I'm not sure this is entirely correct yet, I'm sure there should be a way to get a gem with a hyphen in the name to behave correctly. If I find out I'll post back and let y'all know.

我不确定这是否完全正确,我确信应该有一种方法可以在名称中使用带有连字符的宝石来正确运行。如果我发现我会回复并让你们都知道。