Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.5.6
    • Fix Version/s: JRuby 1.7.0.RC1
    • Component/s: Launcher
    • Labels:
      None
    • Environment:
      Solaris
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      I created a soft link to jruby in my home directory. When running "jruby -v", I got the following error:
      expr: syntax error
      Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main

      I tracked it down to line 32 of bin/jruby, and compared it to the same file in version 1.3. Looks like this:

      if expr "$link" : '/' > /dev/null; then

      Should be:
      if expr "$link" : '^/' > /dev/null; then

      Making the change works for me. This only seems to affect it when I softlink jruby - giving it the full path does not show this error.

        Issue Links

          Activity

          Hide
          Christoph Iserlohn added a comment -

          We've experienced the same problem on OSX 10.8 (see https://trac.macports.org/ticket/36036).
          Our fix escapes the slash: '\/', which is legal according to:
          https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/expr.1.html
          and
          https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/re_format.7.html

          I don't know if that's portable, but I verified that it works on CentOS 6.2.
          But JRUBY-3695 isn't reproducible on CentOS 6.2 anyway.

          Show
          Christoph Iserlohn added a comment - We've experienced the same problem on OSX 10.8 (see https://trac.macports.org/ticket/36036 ). Our fix escapes the slash: '\/', which is legal according to: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/expr.1.html and https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/re_format.7.html I don't know if that's portable, but I verified that it works on CentOS 6.2. But JRUBY-3695 isn't reproducible on CentOS 6.2 anyway.
          Hide
          Charles Oliver Nutter added a comment -

          Escaping the slash may indeed be fine. Investigating.

          Show
          Charles Oliver Nutter added a comment - Escaping the slash may indeed be fine. Investigating.
          Hide
          Charles Oliver Nutter added a comment -

          I tried to reproduce, and then when I couldn't I realized your report points out this is new behavior on Mountain Lion. I am on Lion.

          For most people we recommend installing our native executable (gem install jruby-launcher) which avoids a lot of these little issues with bash (I think). I don't have a problem making the change you recommend, but we need some confirmation across bash/expr/OS versions that it won't break other platforms.

          Can you show me exactly how you symlink JRuby to reproduce this, so I can at least confirm that case doesn't break on Lion with your change?

          Show
          Charles Oliver Nutter added a comment - I tried to reproduce, and then when I couldn't I realized your report points out this is new behavior on Mountain Lion. I am on Lion. For most people we recommend installing our native executable (gem install jruby-launcher) which avoids a lot of these little issues with bash (I think). I don't have a problem making the change you recommend, but we need some confirmation across bash/expr/OS versions that it won't break other platforms. Can you show me exactly how you symlink JRuby to reproduce this, so I can at least confirm that case doesn't break on Lion with your change?
          Hide
          Christoph Iserlohn added a comment -

          The symlink is:
          lrwxr-xr-x 1 root admin 37 18 Sep 23:53 /opt/local/bin/jruby -> /opt/local/share/java/jruby/bin/jruby

          I can confirm that escaping the slash works on Snow Leopard (10.6), Lion (10.7) and Mountain Lion (10.8).

          Show
          Christoph Iserlohn added a comment - The symlink is: lrwxr-xr-x 1 root admin 37 18 Sep 23:53 /opt/local/bin/jruby -> /opt/local/share/java/jruby/bin/jruby I can confirm that escaping the slash works on Snow Leopard (10.6), Lion (10.7) and Mountain Lion (10.8).
          Hide
          Charles Oliver Nutter added a comment -

          Forgot to resolve this.

          commit b1fec0dd242ee473094cbba32dc7a553f24dbb0b
          Author: Charles Oliver Nutter <headius@headius.com>
          Date:   Fri Sep 21 09:10:13 2012 -0500
          
              Try a new technique for finding jruby home that avoids 'expr'.
          
          diff --git a/bin/jruby.bash b/bin/jruby.bash
          old mode 100644
          new mode 100755
          index a1f3e11..0d79b0b
          --- a/bin/jruby.bash
          +++ b/bin/jruby.bash
          @@ -25,24 +25,22 @@ if [ -z "$JAVA_VM" ]; then
             JAVA_VM=-client
           fi
           
          -## resolve links - $0 may be a link to  home
          -PRG=$0
          -progname=`basename "$0"`
          -
          -while [ -h "$PRG" ] ; do
          -  ls=`ls -ld "$PRG"`
          -  link=`expr "$ls" : '.*-> \(.*\)$'`
          -  if expr "$link" : '.*/.*' > /dev/null; then
          -    if expr "$link" : '/' > /dev/null; then
          -      PRG="$link"
          -    else
          -      PRG="`dirname ${PRG}`/${link}"
          -    fi
          -  else
          -    PRG="`dirname $PRG`/$link"
          -  fi
          +# get the absolute path of the executable
          +SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
          +
          +# resolve symlinks
          +while [ -h $SELF_PATH ]; do
          +    # 1) cd to directory of the symlink
          +    # 2) cd to the directory of where the symlink points
          +    # 3) get the pwd
          +    # 4) append the basename
          +    DIR=$(dirname -- "$SELF_PATH")
          +    SYM=$(readlink $SELF_PATH)
          +    SELF_PATH=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM")
           done
           
          +PRG=$SELF_PATH
          +
           JRUBY_HOME_1=`dirname "$PRG"`           # the ./bin dir
           if [ "$JRUBY_HOME_1" = '.' ] ; then
             cwd=`pwd`
          
          Show
          Charles Oliver Nutter added a comment - Forgot to resolve this. commit b1fec0dd242ee473094cbba32dc7a553f24dbb0b Author: Charles Oliver Nutter <headius@headius.com> Date: Fri Sep 21 09:10:13 2012 -0500 Try a new technique for finding jruby home that avoids 'expr'. diff --git a/bin/jruby.bash b/bin/jruby.bash old mode 100644 new mode 100755 index a1f3e11..0d79b0b --- a/bin/jruby.bash +++ b/bin/jruby.bash @@ -25,24 +25,22 @@ if [ -z "$JAVA_VM" ]; then JAVA_VM=-client fi -## resolve links - $0 may be a link to home -PRG=$0 -progname=`basename "$0"` - -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then - if expr "$link" : '/' > /dev/null; then - PRG="$link" - else - PRG="`dirname ${PRG}`/${link}" - fi - else - PRG="`dirname $PRG`/$link" - fi +# get the absolute path of the executable +SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0") + +# resolve symlinks +while [ -h $SELF_PATH ]; do + # 1) cd to directory of the symlink + # 2) cd to the directory of where the symlink points + # 3) get the pwd + # 4) append the basename + DIR=$(dirname -- "$SELF_PATH") + SYM=$(readlink $SELF_PATH) + SELF_PATH=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)/$(basename -- "$SYM") done +PRG=$SELF_PATH + JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir if [ "$JRUBY_HOME_1" = '.' ] ; then cwd=`pwd`

            People

            • Assignee:
              Charles Oliver Nutter
              Reporter:
              Chris Evans
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: