While updating logstash 1.4.2 we encounter - Unable to find JRuby error

Hello Team,

We were trying to update logstash for 1.4.2 to 2.1.0 latest version.

We encounter below issues --

  1. /opt/logstash/bin/logstash: line 22: dirname: command not found
    /opt/logstash/bin/logstash: line 22: //bin/logstash.lib.sh: No such file or directory

-- To resolve this we have edited LOGSTASH_HOME with correct value in logstash.lib.sh & logstash.

  1. /opt/logstash/bin/logstash.lib.sh: line 2: dirname: command not found
    Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME

This ERROR is because of below message we observed in configtest --

/opt/logstash/bin/logstash --configtest -f /etc/logstash/conf.d/logstash.conf
Unable to find JRuby.
If you are a user, this is a bug.
If you are a developer, please run 'rake bootstrap'. Running 'rake' requires the 'ruby' program be available.

We are expecting help from this forum to resolve this.

As above update giving us issues we have tried with 1.4.2 to 1.5.1, 1.5.1 to 1.5.3, 1.5.3 to 2.1.0 .. in each update we were faced this issue.

Issue is not observed when we downgrade to logstash 1.4.2 [ original version ].

Appreciate immediate help.

Thanks,

Datta

The root cause is that there's no dirname binary in the PATH. Why not? What operating system are you running?

On Debian-based systems dirname is installed to /usr/bin as part of the coreutils package so you really have to make an effort for it not to be available.

Hi,

We are having RHEL 6.7.

We can resolve that by updating LOGSTASH_HOME.

Hurdle is for JRuby error..

Actual issue is why these issues are coming for updating logstash 1.4.2.
And how to get to 2.1.0 latest logstash version.

Thanks,

Datta

If you fix the dirname issue I think the rest of your problems are going to go away. Logstash 1.4.2 and 2.1 run just fine on RHEL 6.7 without having to set LOGSTASH_HOME.

Hello,

Thanks for the update.

We have tried this, after resolving dirname we have faced below issues --

In ERROR logs -- Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

In configtest --

Unable to find JRuby.
If you are a user, this is a bug.
If you are a developer, please run 'rake bootstrap'. Running 'rake' requires the 'ruby' program be available.

There were couple of threads but no proper solution given --


Thanks,

Datta

We have tried this, after resolving dirname we have faced below issues --

How did you solve the problem with the missing dirname?

In ERROR logs -- Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

So... make sure the java binary is included in PATH?

Hi,

We have changed below parameter as mentioned & tried which resolved dirname related issue --

basedir=$(cd dirname $0/..; pwd)

basedir=/opt/logstash

This change done for - logstash bin file & logstash.lib.sh file.

Thanks,

Datta

Additional details ..

If we update from logstash 1.4.2 to any upstream version this issue occurs.

Our requirement is to update to latest logstash - 2.1.0

Do not "fix" the problem by modifying the Logstash scripts. The scripts are fine. Your problem is either that you don't have a dirname binary or that your PATH is screwed up so that the dirname that you have isn't available. Fix that. I have nothing more to add in this matter.

Hello,

We have fixed the dirname issue.

Now we are getting below ERROR --

#tail -f /var/log/logstash/logstash.err
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

Below are the contents of logstash.lib.sh --

setup_java() {
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD="java"
JAVACMD="$(which java 2> /dev/null)"
fi

elif [ "$(basename $JAVACMD)" = "drip" ] ; then

export DRIP_INIT_CLASS="org.jruby.main.DripMain"

fi

Resolve full path to the java command.

if [ -f "$JAVACMD" ] ; then
JAVACMD=$(which $JAVACMD 2>/dev/null)
fi

JAVACMD=/usr/bin/java

if [ ! -x "$JAVACMD" ] ; then
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME." 1>&2
exit 1
fi

Our java details are as below --

java -version

openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)

ls -l /usr/bin/java

lrwxrwxrwx 1 root root 72 Dec 3 08:09 /usr/bin/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-0.b17.el6_7.x86_64/jre/bin/java

So Could you please help in this regards.

Thanks,

Datta

Could you please help in fixing this.

Additional Information --

I have one more environment having same configuration works well with version 2.1.0.
This environment got update from version 1.5.3.

Like above here no configuration changes required.

Now for above issue we did update from 1.4.2 to 2.1.0.

Can somebody help in understanding what could be the cause.

Thanks,

Datta

Are you setting JAVA_HOME? What's the contents of JAVACMD just as the shell script bails out?

JAVA_HOME, JAVACMD are not set at system level.

In the working environment also it is not set.

What's the value of those variables in the script? Instead of running /opt/logstash/bin/logstash, run sh -x /opt/logstash/bin/logstash to get additional debugging output.

sh -x /opt/logstash/bin/logstash

  • unset CDPATH
  • . /etc/sysconfig/logstash
    ++ JAVACMD=/usr/bin/java
    ++ KILL_ON_STOP_TIMEOUT=0
  • . /opt/logstash/bin/logstash.lib.sh
    ++ unset CDPATH
    ++ LOGSTASH_HOME=/opt/logstash
    ++ export LOGSTASH_HOME
    ++ LS_HEAP_SIZE=1g
  • setup
  • '[' /usr/bin/java ']'
  • echo 'checking JAVACMD'
    checking JAVACMD
  • echo /usr/bin/java
    /usr/bin/java
    ++ basename /usr/bin/java
  • '[' java = drip ']'
  • '[' '' = 1 ']'
  • '[' '' = 1 ']'
  • echo 'checking setup java call'
    checking setup java call
  • setup_java
  • '[' -z /usr/bin/java ']'
  • '[' -f /usr/bin/java ']'
    ++ which /usr/bin/java
  • JAVACMD=/usr/bin/java
  • '[' '!' -x /usr/bin/java ']'
  • '[' '' ']'
  • JAVA_OPTS=-XX:+UseParNewGC
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/logstash/heapdump.hprof'
  • '[' '' ']'
  • '[' 1g ']'
  • JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/logstash/heapdump.hprof -Xmx1g'
  • '[' '' ']'
  • export JAVACMD
  • export JAVA_OPTS
  • setup_vendored_jruby
  • JRUBY_BIN=/opt/logstash/vendor/jruby/bin/jruby
  • '[' '!' -f /opt/logstash/vendor/jruby/bin/jruby ']'
  • VENDORED_JRUBY=1
  • case $1 in
  • ruby_exec /opt/logstash/lib/bootstrap/environment.rb logstash/runner.rb
  • '[' -z 1 ']'
  • '[' '' ']'
    ++ jruby_opts
    ++ printf %s --1.9
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:+UseParNewGC'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:+UseConcMarkSweepGC'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-Djava.awt.headless=true'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:CMSInitiatingOccupancyFraction=75'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:+UseCMSInitiatingOccupancyOnly'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:+HeapDumpOnOutOfMemoryError'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-XX:HeapDumpPath=/opt/logstash/heapdump.hprof'
    ++ for i in '$JAVA_OPTS'
    ++ printf %s ' -J-Xmx1g'
  • exec /opt/logstash/vendor/jruby/bin/jruby --1.9 -J-XX:+UseParNewGC -J-XX:+UseConcMarkSweepGC -J-Djava.awt.headless=true -J-XX:CMSInitiatingOccupancyFraction=75 -J-XX:+UseCMSInitiatingOccupancyOnly -J-XX:+HeapDumpOnOutOfMemoryError -J-XX:HeapDumpPath=/opt/logstash/heapdump.hprof -J-Xmx1g /opt/logstash/lib/bootstrap/environment.rb logstash/runner.rb
    No command given

So... what's the problem again? Logstash is apparently starting for you.

No It is still not starting getting below ERROR message --

tail -f /var/log/logstash/logstash.err
Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

sh -x /opt/logstash/bin/logstash is stuck at below point --

++ printf %s ' -J-Xmx1g'

  • exec /opt/logstash/vendor/jruby/bin/jruby --1.9 -J-XX:+UseParNewGC -J-XX:+UseConcMarkSweepGC -J-Djava.awt.headless=true -J-XX:CMSInitiatingOccupancyFraction=75 -J-XX:+UseCMSInitiatingOccupancyOnly -J-XX:+HeapDumpOnOutOfMemoryError -J-XX:HeapDumpPath=/opt/logstash/heapdump.hprof -J-Xmx1g /opt/logstash/lib/bootstrap/environment.rb logstash/runner.rb
    No command given

Usage: logstash [command args]
Run a command with the --help flag to see the arguments.
For example: logstash agent --help

Available commands:
agent - runs the logstash agent
version - emits version info about this logstash

No. Logstash is starting. The "No command given" text and everything that follows comes from Logstash. The "Could not find any executable java binary" message at the end of logstash.err must be from previous runs.

Actually service mentioned not running --

#service logstash status
logstash is not running

tail -f /var/log/logstash/logstash.err

Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME.

Everytime we restart the logstash service we get mentioned logstash ERROR

So Logstash starts when run from the shell but not when run as a service. You need to make sure PATH and/or JAVA_HOME is correctly set also in the init script.