Logstash: Windows: logstash.bat doesn't work if the directory contains spaces

Created on 16 Dec 2016  Â·  22Comments  Â·  Source: elastic/logstash

Just installed LogStash (after much trouble in getting JRuby to work in Win7...). However running bin\logstash.bat results in:

Unable to find JRuby.

The reason is complex but TL DR: Maybe you could just use %JRUBY_HOME% which is set when JRuby is installed.

The long version...

It seems setup is expecting a "vendor" version of JRuby inside LogStash:

set JRUBY_BIN="%LS_HOME%\vendor\jruby\bin\jruby"
if exist "%JRUBY_BIN%" (
  set VENDORED_JRUBY=1
goto finally
) else (
goto missing_jruby
)

However no such file is found. The closest thing we have is C:\Prg\monitoring\logstash\vendor\bundle\jruby\1.9\bin but there is no jruby file in there. Indeed, under Windows there should presumably be a jruby.exe in there.

Most helpful comment

i had same pb after installation.
As an old dos user, i saw that my logstash was unzip under a folder with a space in the name like : D:\myProgram Files\logstash-5.6.3> and it doesn't find jruby this way.
I move the directory upper into D:\logstash-5.6.3> (no spaces in full name) and i can run it from D:\logstash-5.6.3\bin>logstash.bat without pb.
( More : to run it from D:\logstash-5.6.3> must add quotes "bin/logstash.bat" )
HTH

All 22 comments

are you trying to use logstash from a packaged release (.zip) or git repo for development?

Packaged.
I tried to point JRUBY_BIN at my JRuby 9.0 but apparently it's the wrong version. The bundled "vendor " version seems to be 1.9 but I could not find that anywhere for download???

@cawoodm you don't have to download jruby at all, logstash already comes packaged with it.

you only need to have JAVA_HOME defined, and the run bin\logstash.bat -h (or bin\logstash)

@cawoodm are you still seeing problems? if not feel free to close the issue

I'll give it a whirl tomorrow again but as I originally posted - running logstash resulted in "Unable to find JRuby." before I had done anything (JAVA_HOME was set, without trailing slash to JDK 1.8). IMO the batch was looking for a unix-like executable "jruby" (without extension),

I deleted and re-installed 5.1.1 and now it works. It could well be that I extracted logstash-5.1.1.zip using Windows' own unzip function (which has some issues) and ended up with an incomplete install.

So, I ran into the same issue last night. And I tried this morning again, it worked.
Before I ran logstash.bat, I executed setup.bat first for this time.
I don't it is the reboot or the setup.bat that made it work, but it's worth a try.

Hope it helps :)

Ran into this just now, only with logstash-plugin and setup.bat first worked

plz tell me the solution i m going through the same problem ...

Hey @saigal06, could you share where are you placing your config file? I'd be able to help you as I was also facing the same issue and figured it out.

@saigal06

Modify setup.bat

if not exist "%JRUBY_BIN%" ( --> if not exist %JRUBY_BIN% (

i had same pb after installation.
As an old dos user, i saw that my logstash was unzip under a folder with a space in the name like : D:\myProgram Files\logstash-5.6.3> and it doesn't find jruby this way.
I move the directory upper into D:\logstash-5.6.3> (no spaces in full name) and i can run it from D:\logstash-5.6.3\bin>logstash.bat without pb.
( More : to run it from D:\logstash-5.6.3> must add quotes "bin/logstash.bat" )
HTH

Yeah 5.6.3 zip installer has issues with dir structure for jruby which breaks the batch files. Rolling back to 5.6.2 worked for me.

Just an update - this is still broken. Removing the quotes from the JRUBY_BIN check _does_ get past that error. However it will still fail when attempting to use the working directory with the spaces.

That did the trick for me @pirelaurent, thanks!!! I also had to set JRUBY_HOME before doing anything as well.

Setting JRUBY_home is not supported and while it may work around it is not
intended for use. Please don’t recommend this fix. I am glad for those who
can use this work around, but this is a bug and not feature.

On Mon, Oct 30, 2017 at 2:11 PM Rufus Knight notifications@github.com
wrote:

That did the trick for me @pirelaurent https://github.com/pirelaurent,
thanks!!! I also had to set JRUBY_HOME before doing anything as well.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/elastic/logstash/issues/6426#issuecomment-340585811,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIC6vof_RYaPWtF-7-Jvuyz0B504GM0ks5sxjuTgaJpZM4LO80J
.

@pirelaurent's the trick is working, Thanks a lot.
just remove the space in directory names, eg. my previous dir was C:\Elastic Stack\logstash-5.6.3
I removed the space and changed to C:\ElasticStack\logstash-5.6.3, it is working finally.

Solution found!

When calling the logstash.bat file full path of the bat file must be used and in short format.

For example in my case I have logstash stored in C:\Program Files\Logstash, then there are subfolders for each Logstash version. So in the root folder I have logstash.bat that contains this.

"%~dps0logstash-5.6.4\bin\logstash.bat" -f %~dps0logstash-config\config\config.conf -r

When I run logstash.bat from the C:\Program Files\Logstash folder it will convert the current path location to a short name version.

C:\Program Files\Logstash\logstash-5.6.4bin\logstash.bat becomes C:\Progra~1\Logstash\logstash-5.6.4bin\logstash.bat

Found the solution at this link http://www.robvanderwoude.com/shorts.php

I have updated the issue's description to hopefully accurately represent the bug.

Have unzipped the logstash version 6.1.1 but when i run the logstash.bat file i m getting the following error
The system cannot find the path specified.
"could not find jruby in C:\Program Files\logstash-6.1.1\vendorjruby"

Saw all the previous discussion and worked on those solutions since my problem is not solved but i checked the vendor directory jruby file was there.

Should i modify the setup.batch file

set JRUBY_BIN="%LS_HOME%\vendorjruby\binjruby"
if not exist "%JRUBY_BIN%" (
echo "could not find jruby in %LS_HOME%\vendorjruby" 1>&2
exit /b 1
)

instead of '%LS_HOME%' should i give C:\Program Files\logstash-6.1.1 tried that also but not working.

I have the same problem with logstash 6.3.0 on windows.

the path of jruby bin is: vendor\bundlejruby\2.3.0\bin

but, jruby executor is not located on the bin or other directory

i had same pb after installation.
As an old dos user, i saw that my logstash was unzip under a folder with a space in the name like : D:\myProgram Files\logstash-5.6.3> and it doesn't find jruby this way.
I move the directory upper into D:\logstash-5.6.3> (no spaces in full name) and i can run it from D:\logstash-5.6.3\bin>logstash.bat without pb.
( More : to run it from D:\logstash-5.6.3> must add quotes "bin/logstash.bat" )
HTH

Thanks a lot!!!

Was this page helpful?
0 / 5 - 0 ratings