History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1373
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Nick Sieger
Reporter: Martin Krauskopf
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

Cannot run JRuby through 'java' when having space in path in JRuby's home

Created: 20/Sep/07 05:10 AM   Updated: 22/Dec/07 06:28 AM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.0.1
Fix Version/s: JRuby 1.0.2, JRuby 1.1RC2

Time Tracking:
Not Specified


 Description  « Hide
The problem is that some people might install JRuby into Program Files directory on Windows. More likely in case of bundled JRuby within NetBeans. In such case running JRuby runtime using java command does not work.

You might see simple steps to reproduce in the NetBeans issue 108808 in the comment from mkrauskopf Thu Sep 6 16:09:24 +0000 2007.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Mike Norman - 20/Sep/07 09:19 AM
This is a common problem when running on Windows.

For 'modern' Windows versions (a.k.a. > NT4, does NOT work for win95/98),
the following 'weird' script commands iteratively replace directory components
in a path with the DOS 8.3 equivalent (i.e. "Program Files" is replaced with "PROGRA~1"):

A file XXX.cmd:

@REM User or Environment provides a path to JAVA_HOME

@REM clear _FIXPATH variable
set _FIXPATH=

@REM call :fixpath macro with current value of JAVA_HOME
call :fixpath "%JAVA_HOME%"
@REM re-set JAVA_HOME with results of :fixpath macro
set JAVA_HOME=%_FIXPATH:~1%

@REM invoke java program
%JAVA_HOME%\bin\java -cp ....

goto :EOF

:fixpath
if not %1.==. (
for /f "tokens=1* delims=;" %%a in (%1) do (
call :shortfilename "%%a" & call :fixpath "%%b"
)
)
goto :EOF
:shortfilename
for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi
goto :EOF


Charles Oliver Nutter - 19/Oct/07 08:59 PM
Mike, would it be possible for you to tweak our existing .bat scripts to do this path trickery and provide a patch? We're fresh out of bat/cmd experts here and I'd really like to see this fixed.

Nick Sieger - 30/Oct/07 10:46 PM
I think this is fixed. I made a dist-bin, unpacked in a directory with spaces, and was able to run. Please reopen or report a new issue if not.

Alex Durgin - 30/Oct/07 11:50 PM
I'm one of those with jruby in my program files directory (C:\Program Files\Java\JRuby). The 4830 patch breaks the launch process. The following error is reported:

'""C:\Program' is not recognized as an internal or external command,
operable program or batch file.


Nick Sieger - 31/Oct/07 09:49 AM - edited
Hey Alex, can you give me specifics about your setup?
  • Do you have Java itself installed in Program Files?
  • How do you launch JRuby? Do you add %JRUBY_HOME%\bin to your path and type 'jruby'? Or do you path over to the jruby.bat file?

Nick Sieger - 31/Oct/07 10:30 AM
Also, can you provide your values for PATH, CLASSPATH and JAVA_HOME? I suspect you may have extra quotes in one or more of them.

Alex Durgin - 31/Oct/07 11:39 AM

Yes, I do have Java installed in Program Files

I don't have JRUBY_HOME set, but I do have the path to my jruby bin in the PATH environment variable.

PATH:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\WBEM;C:\ruby\bin;C:\Program Files\Java\jruby\bin;C:\Program Files\Java\jdk1.6.0_02\bin;C:\Program Files\Subversion\bin;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\Microsoft SQL Server\MSSQL\Upgrade

JAVA_HOME:

C:\Program Files\Java\jdk1.6.0_02

CLASSPATH (I'm not sure what these are as I haven't set any of these items myself):

.;C:\Program Files\Java\jre1.5.0_06\lib\ext\QTJava.zip


Tom Bell - 04/Nov/07 12:17 PM
FIXPATH will not work in some instances though it will work in most.

The number after the tilde(~) in the short name is not always 1. I've had problems installing software and discovered "Program Files" resolving to "PROGRA~2"
My assumption is windows uses ~1 for the first occurrence of that short name and ~2 for the second and so on. This would unfortunately mean it would be impossible to accurately determine the short name for any given long name other than by querying on the machine itself - i.e. character manipulation can never work 100%

There is also a problem in that if the long name contains a period it and the first three characters after it are appended to the generated short name.( On checking I've discovered this is a simplification of how it works, but we end up with a 8.3 format name rather than just 8) So as the default Java installation contains the release number as part of the directory name you would need to handle this as well.

For example

"jdk1.6.0_03" becomes "JDK16~1.0_0" - I don't understand quite how it did that either !


Charles Oliver Nutter - 07/Nov/07 12:49 AM
Can those of you still having trouble open bugs with your specific cases? This one was resolve for the original report, but there are obviously edge cases that should be chased down separately.