Issue #11316 has been updated by Leif Eriksen.


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

rhc.bat appears to be correct.

~~~
@ECHO OFF
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
GOTO :EOF
:WinNT
@"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.

----------------------------------------
Bug #11316: ruby 2.2 on Windows generates incorrect BAT files for gems
https://bugs.ruby-lang.org/issues/11316#change-53288

* Author: Jeka Der
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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-2.6.0.1.gem (100%)
Successfully installed httpclient-2.6.0.1
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-2.6.0.1
Installing ri documentation for httpclient-2.6.0.1
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
conds
10 gems installed


4) 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:


@ECHO OFF
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
GOTO :EOF
:WinNT
@""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" %*




-- 
https://bugs.ruby-lang.org/