nullnullnull
nullnullnull

Reputation: 8189

While executing gem, unknown command

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?

Upvotes: 18

Views: 56662

Answers (3)

BEF Meshesha
BEF Meshesha

Reputation: 19

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.

Upvotes: 1

David Underwood
David Underwood

Reputation: 4966

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

Upvotes: 5

Andrew Marshall
Andrew Marshall

Reputation: 96904

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.

Upvotes: 35

Related Questions