Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem which cannot find gem despite it being installed

Tags:

ruby

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

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

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

# 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

like image 813
Ceilingfish Avatar asked Feb 14 '10 17:02

Ceilingfish


People also ask

How do I know if gem is installed?

To check if a specific version is installed, just add --version , e.g.: gem list -i compass --version 0.12.

Is gem installed with Ruby?

Ruby comes with RubyGems by default since version 1.9, previous Ruby versions require RubyGems to be installed by hand.

How do I resolve gem dependencies?

Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.

How do I install bundles to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .


1 Answers

It's not the hyphen.

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

$ 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.

$ 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:

$ 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).

like image 67
Dave Nolan Avatar answered Oct 26 '22 16:10

Dave Nolan