Skip to content
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

Implement suggested fix from #30606 #33405

Closed
wants to merge 2 commits into from
Closed

Conversation

LeeDr
Copy link
Contributor

@LeeDr LeeDr commented Sep 5, 2018

Fixes: #30606

While setting up my new Windows 10 Pro laptop I took the default path for installing the Java 10 JRE;
"C:\Program Files (x86)\Common Files\Oracle\Java"

I'm running a Kibana script that downloads and starts the latest elasticsearch snapshot but it kept failing with this error;
ERROR \Common was unexpected at this time.

@Dobatymo and @lashchev suggested variations on a fix in #30606. I applied the changes exactly as Lashchev suggested here #30606 (comment)

It resolved this problem for me.

NOTE: In my case, I had the JRE installed to that default path, and although I had the jdk 10 installed, I did not have JAVA_HOME set, so it was using the java executable from the JRE that was in my path var.

If I set my JAVA_HOME variable (my jdk path has no spaces or parenthesis) I can start elasticsearch without this fix. But we should fix this problem since it would a common case for Windows users to download the JRE, take the default installation path, and then try to start Elasticsearch.

@LeeDr LeeDr added the :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts label Sep 5, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jasontedor jasontedor self-requested a review September 7, 2018 13:42
@LeeDr LeeDr added the review label Sep 7, 2018
@LeeDr
Copy link
Contributor Author

LeeDr commented Sep 19, 2018

@nogginbox This PR (specifically the 2nd commit) does also have those double-quotes removed.

@nogginbox
Copy link
Contributor

@LeeDr really sorry. I did not see that. I somehow copied the code from the first commit only. Thanks for taking the time with me when the problem was PEBKAC.

@rjernst rjernst removed the review label Oct 10, 2018
@LeeDr
Copy link
Contributor Author

LeeDr commented Oct 19, 2018

@jasontedor I'm not sure what to do with the failures above. Do I retest? In Kibana we comment "Jenkins test this" to run CI again. Is it the same here?

@pgomulka
Copy link
Contributor

I have managed to reproduce that as well:
steps for me were:

using java from a path with spaces and parenthesis

set JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_181 
set PATH=%JAVA_HOME%
bin\elasticsearch.bat

\Java\jre1.8.0_181\bin\java.exe" -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory""` was unexpected at this time.

that failure is from elasticsearch-env.bat : 60

fixing this as advised

  for /f "tokens=* usebackq" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory"`) do set ES_TMPDIR=%%a

will let me to fail in elasticsearch.bat:46 (addressed in this PR)

\Java\jre1.8.0_181\bin\java.exe" -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_JVM_OPTIONS!" || echo jvm_options_parser_failed"`) was unexpected at this time.

and only then when fixed with the snipped from the PR it will let me start

for /F "usebackq delims=" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_JVM_OPTIONS!" ^|^| echo jvm_options_parser_failed`) do set JVM_OPTIONS=%%a

I will update this PR with the fix I needed in elasticserach-env.bat as well

@jasontedor
Copy link
Member

@pgomulka Thanks for looking into this. Are the some packaging tests that we can add that fail before these changes, and then pass with the changes that you are suggesting. That is what we should have before pulling this change in, so that we are less likely to continually break in these situations when we do maintenance on these scripts.

@pgomulka
Copy link
Contributor

@jasontedor agree, packaging test would be really useful for this. Will look into adding more scenarios

pgomulka added a commit that referenced this pull request Apr 2, 2019
the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes #38578
closes #38624
closes #33405
closes #30606
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Apr 3, 2019
…39712)

the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes elastic#38578
closes elastic#38624
closes elastic#33405
closes elastic#30606
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Apr 4, 2019
the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes elastic#38578
closes elastic#38624
closes elastic#33405
closes elastic#30606
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request Apr 4, 2019
the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes elastic#38578
closes elastic#38624
closes elastic#33405
closes elastic#30606
pgomulka added a commit that referenced this pull request Apr 5, 2019
…40768)

the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes #38578
closes #38624
closes #33405
closes #30606
backports:
* Bat scripts to work with JAVA_HOME with parentheses(#39712)
* Link to SYSTEM_JAVA_HOME on windows (#40806)
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
the elasticsearch.bat and elasticsearch-env.bat won't work if JAVA
contains parentheses. This seems to be the limitation of FOR /F IN
(command) DO syntax.
The JAVA variable present in a command contains a path to a binary to
start elasticsearch (with spaces & parens). We can workaround the
problem of spaces and parentheses in this path by referring this
variable with a CALL command.
Note that executing binaries with CALL is an undocumented behaviour (but works)
closes elastic#38578
closes elastic#38624
closes elastic#33405
closes elastic#30606
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

windows elasticsearch.bat file has problems with certains paths
8 participants