Google search bar

December 24, 2008

Updating RubyGems broke the gem command

On a windows box where I have ruby installed at "C:\Program Files\ruby\" rather than "C:\ruby\".

I ran:
gem update --system

The result was that the next time I tried to execute the gem command I got the following:

C:\>gem
The filename, directory name, or volume label syntax is incorrect.


I found that the gem.bat file had been changed and there was an extra double-quote on two lines.

@"ruby.exe"" "c:/Program Files/ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9

And

@"ruby.exe"" "%~dpn0" %*

In both these cases, where there were two juxtaposed double-quotes (two double-quotes in a row), I had to remove one of the double quotes. Yielding:

@"ruby.exe" "c:/Program Files/ruby/bin/gem" %1 %2 %3 %4 %5 %6 %7 %8 %9

And

@"ruby.exe" "%~dpn0" %*


Problem was solved. I found a comment on the RubyGems forum that agreed with my fix.

4 comments:

Anonymous said...

Thanks for posting this!

Ari Zelanko said...

This is cool. My first comment on my little blog.

Geoffers said...

You are a lifesaver! This is the only solution to this weird problem I've found in days of searching. Thanks.

Anonymous said...

I had to apply the same fix on XP(win32) rails.bat, rails v-2.3.2,
from instantrails v-186-27-rc2