-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix handling of spaces in Windows paths #21921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of spaces in Windows paths #21921
Conversation
This commit fixes the handling of spaces in Windows paths. The current mechanism works fine in a path that contains a single space, but fails on a path that contains multiple spaces. With this commit, that is no longer the case.
|
I've manually tested this for both running Elasticsearch from the command line and the service, and with paths that contain zero, one, two, and three spaces and everything works as expected. |
ngbrown
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When setting environment variables, the full path should be included in the quotes.
|
|
||
| IF DEFINED JAVA_HOME ( | ||
| set JAVA=%JAVA_HOME%\bin\java.exe | ||
| set JAVA="%JAVA_HOME%"\bin\java.exe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quotes should surround the entire path, including the .exe.
|
|
||
| IF DEFINED JAVA_HOME ( | ||
| SET JAVA=%JAVA_HOME%\bin\java.exe | ||
| SET JAVA="%JAVA_HOME%"\bin\java.exe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quotes should surround the entire path, including the .exe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? I tested it with this change. Do you have an example where this would break without your suggestion?
|
This LGTM. Should we consider (in a follow up) having our integ test dir which contains a space have two spaces (I did not realize it was possible to have different behavior for one vs two spaces). |
Yes, I was thinking the same thing. Lacking packaging tests, that's test best that we can do but it's been really effective for us in the past. |
This commit fixes the handling of spaces in Windows paths. The current mechanism works fine in a path that contains a single space, but fails on a path that contains multiple spaces. With this commit, that is no longer the case. Relates #21921
This commit fixes the handling of spaces in Windows paths. The current mechanism works fine in a path that contains a single space, but fails on a path that contains multiple spaces. With this commit, that is no longer the case. Relates #21921
This commit fixes the handling of spaces in Windows paths. The current mechanism works fine in a path that contains a single space, but fails on a path that contains multiple spaces. With this commit, that is no longer the case. Relates #21921
|
Thanks @rjernst. |
|
When I read this it seems the issue is not closed and included in a release package but when I download the elasticsearch zip from here https://www.elastic.co/downloads/elasticsearch it's already included. Did something went wrong? This fix in not working for me. I tested the version 5.1.1 on windows 7 (x64) and windows server 2012 R2 (x64) standard and had the same issue every time. The quote around the %JAVA_HOME% and %JAVA% variables are not placed correctly which prevent the scripts to start the node and to detect the JVM version which always default the service installation to the x86 version. My JAVA_HOME variable is set with the value: C:\Program Files\Java\jdk1.8.0_111 ######Result of the elasticsearch.bat execution before the fix: ######Result of the elasticsearch-service.bat execution before the fix: To fix the problem I had to do the following changes:
Here are the files with the fixes: elasticsearch-service.bat.txt Hope it helps. |
|
@yannlebel If you remove the trailing backslash from |
|
Sorry my mistake I didn't read the changes in the commit correctly and thought this was the PR and #22132 was an issue. I tried without the trailing slash and indead it is working. |


This commit fixes the handling of spaces in Windows paths. The current
mechanism works fine in a path that contains a single space, but fails
on a path that contains multiple spaces. With this commit, that is no
longer the case.
Relates #20809, relates #21525