Bug #11316


ruby 2.2 on Windows generates incorrect BAT files for gems

Added by jekader (Jeka Der) almost 7 years ago. Updated almost 7 years ago.

Target version:
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]


In Ruby 2.2 on Windows it's impossible to install the "rhc" gem since the BAT wrapper has a typo.

steps to reproduce:

  1. install ruby 2.2.2 into a directory with spacer (C:\Program Files\ruby22)
  2. install git
  3. open console and install "rhc" gem:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]

C:\Windows\system32>gem install rhc
Fetching: open4-1.3.4.gem (100%)
Successfully installed open4-1.3.4
Fetching: httpclient- (100%)
Successfully installed httpclient-
Fetching: highline-1.6.21.gem (100%)
Successfully installed highline-1.6.21
Fetching: commander-4.2.1.gem (100%)
Successfully installed commander-4.2.1
Fetching: archive-tar-minitar-0.5.2.gem (100%)
Successfully installed archive-tar-minitar-0.5.2
Fetching: net-ssh-2.9.2.gem (100%)
Successfully installed net-ssh-2.9.2
Fetching: net-ssh-gateway-1.2.0.gem (100%)
Successfully installed net-ssh-gateway-1.2.0
Fetching: net-ssh-multi-1.2.1.gem (100%)
Successfully installed net-ssh-multi-1.2.1
Fetching: net-scp-1.2.1.gem (100%)
Successfully installed net-scp-1.2.1
Fetching: rhc-1.35.4.gem (100%)

If this is your first time installing the RHC tools, please run 'rhc setup'

Successfully installed rhc-1.35.4
Parsing documentation for open4-1.3.4
Installing ri documentation for open4-1.3.4
Parsing documentation for httpclient-
Installing ri documentation for httpclient-
Parsing documentation for highline-1.6.21
Installing ri documentation for highline-1.6.21
Parsing documentation for commander-4.2.1
Installing ri documentation for commander-4.2.1
Parsing documentation for archive-tar-minitar-0.5.2
Installing ri documentation for archive-tar-minitar-0.5.2
Parsing documentation for net-ssh-2.9.2
Installing ri documentation for net-ssh-2.9.2
Parsing documentation for net-ssh-gateway-1.2.0
Installing ri documentation for net-ssh-gateway-1.2.0
Parsing documentation for net-ssh-multi-1.2.1
Installing ri documentation for net-ssh-multi-1.2.1
Parsing documentation for net-scp-1.2.1
Installing ri documentation for net-scp-1.2.1
Parsing documentation for rhc-1.35.4
Installing ri documentation for rhc-1.35.4
Done installing documentation for open4, httpclient, highline, commander, archiv
e-tar-minitar, net-ssh, net-ssh-gateway, net-ssh-multi, net-scp, rhc after 17 se
10 gems installed
  1. try to run it:
C:\Windows\system32>rhc --help
'""C:\My' is not recognized as an internal or external command,
operable program or batch file.

here's rhc.bat:

IF NOT "%~f0" == "~f0" GOTO :WinNT
@""C:\Program Files\ruby22\bin\ruby.exe" "C:/Program Files/ruby22/bin/rhc" %1 %2 %3 %4 %5 %6 %7 %8 %9
@""C:\Program Files\ruby22\bin\ruby.exe" "%~dpn0" %*

To make this work I had to remove the extra double quote in the last line:

@"C:\Program Files\ruby22\bin\ruby.exe" "%~dpn0" %*

Updated by jekader (Jeka Der) almost 7 years ago

I forgot to mention that this works fine with ruby 2.1. The bat file there looks like this:

IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Program Files/ruby21/bin/rhc" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"ruby.exe" "%~dpn0" %*

Updated by leriksen (Leif Eriksen) almost 7 years ago

I tested this against ruby 2.2.2p95 x64-mingw without issue.

rhc.bat appears to be correct.

IF NOT "%~f0" == "~f0" GOTO :WinNT
@"c:\Ruby22-x64\bin\ruby.exe" "c:/Ruby22-x64/bin/rhc" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"c:\Ruby22-x64\bin\ruby.exe" "%~dpn0" %*

If I get time later today I'll install a 32-bit Windows version of Ruby 2.2 and try again.

One point - I had to install net-ssh-2.9.3.beta1 to get rhc to work at all - dl/import error.

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Description updated (diff)
  • Status changed from Open to Third Party's Issue

It's generated by rubygems, not ruby's installer.

Updated by leriksen (Leif Eriksen) almost 7 years ago

No issue with a fresh ruby-2.2.2-p95-x86-mingw either.

Deka, what do you get for "gem --version" ? Check which gem exe is getting picked up in your path with "where gem" as well.

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Status changed from Third Party's Issue to Rejected

Updated by usa (Usaku NAKAMURA) almost 7 years ago

  • Status changed from Rejected to Closed

and imported to trunk at r49511.

Updated by jekader (Jeka Der) almost 7 years ago

Hi and sorry for delay. My gem version is 2.4.5:

C:\Windows\system32>gem --version

C:\Windows\system32>where gem
C:\Program Files\ruby22\bin\gem
C:\Program Files\ruby22\bin\gem.bat

C:\Windows\system32>rhc --help
'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.

This only happens when the install path contains spaces. Without spaces there are no extra quotes(and even if there were none it would still work). Anyways, I will open an issue with rubygems about this.

Updated by jekader (Jeka Der) almost 7 years ago

Update: just tested with rubygems 2.4.8 and it generates BAT files correctly. I hope this version is planned for inclusion into Windows builds of ruby.


Also available in: Atom PDF