Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

While executing gem, unknown command

Tags:

ruby

rubygems

gem

Whenever I enter a gem command, such as

gem "tilt"

or

gem "mysql"

I get this error:

While executing gem ... <RuntimeError>
Unknown command tilt

When I run gem list, both tilt and mysql show up on the list, so they are installed. In fact, I get this error with every item on the list. What could be causing this?

like image 549
nullnullnull Avatar asked Jun 02 '12 15:06

nullnullnull


3 Answers

gem isn't lying to you, they aren't valid gem commands.

Perhaps you're confusing the command line with Bundler? For example, adding

gem "tilt"

to a Gemfile and running bundle install will install tilt. But Bundler uses its own syntax, and isn't a shell script. To install tilt using the gem binary directly you'd have to do:

gem install tilt

Running gem help will give you a list of gem's command line arguments.

like image 53
Andrew Marshall Avatar answered Nov 20 '22 07:11

Andrew Marshall


You're using the Gemfile syntax and you should be using the commandline syntax. Give this a try:

gem install mysql2 -v 0.2.7
like image 4
David Underwood Avatar answered Nov 20 '22 08:11

David Underwood


Make sure your syntax is correct for more guidelines you can type

gem help

To see the acceptable syntax for ruby,

If you get this error "You don't have write permissions for the /Library"

You can always add sudo to elevate privileges.

eg. sudo gem install <gemname>

Using sudo before your code and that will give you administrative access (after you type your computer password).

After that you may have to run bundle install to install the gem.

like image 1
BEF Meshesha Avatar answered Nov 20 '22 07:11

BEF Meshesha