I'm trying to run the ruby gem "mongo3" (http://mongo3.com/)
I'm new to gem, but I would think that running "gem mongo3" should execute it, but I get this error:
chris@Zombie:~$ gem mongo3
ERROR: While executing gem ... (RuntimeError)
Unknown command mongo3
So I did "gem which mongo3" and it said it is located at "/var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb". I then ran "ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb" with the following result:
chris@Zombie:~$ ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb
/var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3/node.rb:1:in `require': no such file to load -- json (LoadError)
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3/node.rb:1
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require_all_libs_relative_to'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `each'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require_all_libs_relative_to'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:53
I'm not sure what I'm doing wrong - I suspect that ruby and gems are confused about where the gems should be loaded from or some开发者_JAVA技巧thing. Thanks!
You don't need to do a gem mongo3
or ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb
. Instead, just simply run mongo3
.
Make sure to follow the usage instructions here to configure it or you'll get runtime errors.
Edit: If you don't install the gem using sudo
, then you won't have proper write access to /usr/bin
, meaning the mongo3
executable will not be in your path. You'll probably see a warning like this when installing:
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /home/chris/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
You have two options: install the gem using sudo gem install mongo3
so it properly links to /usr/bin
, or add /home/chris/.gem/ruby/1.8/bin
to your path.
精彩评论