Solr
  1. Solr
  2. SOLR-7067

bin/solr won't run under bash 4.2+

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 5.0, 5.1, 6.0
    • Fix Version/s: 4.10.4, 5.0, 5.1, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      I upgraded to OS X Yosemite 10.10.2 today, and the bash version went from 3.2.53(1)-release (x86_64-apple-darwin14) on 10.10.1 to 4.3.30(1)-release (x86_64-apple-darwin14.0.0).

      When I try to run bin/solr, I get:

      bin/solr: line 55: [: is: binary operator expected
      bin/solr: line 58: [: is: binary operator expected
      This script requires extracting a WAR file with either the jar or unzip utility, please install these utilities or contact your administrator for assistance.
      

      the relevant section of the script is:

      52: hasJar=$(which jar 2>/dev/null)
      53: hasUnzip=$(which unzip 2>/dev/null)
      54: 
      55: if [ ${hasJar} ]; then
      56:   unzipCommand="$hasJar xf"
      57: else
      58:   if [ ${hasUnzip} ]; then
      59:     unzipCommand="$hasUnzip"
      60:   else
      61:     echo -e "This script requires extracting a WAR file with either the jar or unzip utility, please install these utilities or contact your administrator for assistance."
      62:     exit 1
      63:   fi
      64: fi
      
      1. SOLR-7067.patch
        3 kB
        Steve Rowe
      2. SOLR-7067.patch
        2 kB
        Steve Rowe

        Activity

        Hide
        Steve Rowe added a comment -

        Patch addressing the issue.

        I also took the opportunity to switch away from usage of which to discover whether executables exist (which is apparently not very portable), and instead used POSIX-compliant command -v. See the first answer to this StackOverflow post: http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script.

        Can somebody do a sanity check on OS X 10.10.1 and other Unix-ish platforms? I'll check on Debian (not sure what version I have ATM) in a minute.

        I want to get this into 5.0.

        Show
        Steve Rowe added a comment - Patch addressing the issue. I also took the opportunity to switch away from usage of which to discover whether executables exist ( which is apparently not very portable), and instead used POSIX-compliant command -v . See the first answer to this StackOverflow post: http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script . Can somebody do a sanity check on OS X 10.10.1 and other Unix-ish platforms? I'll check on Debian (not sure what version I have ATM) in a minute. I want to get this into 5.0.
        Hide
        Steve Rowe added a comment -

        Updated patch.

        Timothy Potter told me offline that with the original patch, bin/solr healthcheck -c whatever fails when the war has not yet been unpacked. I reproduced:

        $ bin/solr healthcheck -c testing
        bin/solr: line 386: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/jar xf: No such file or directory
        Error: Could not find or load main class org.apache.solr.util.SolrCLI
        

        This patch fixes that problem, and also switches from using command -v to hash to check for executables, which the above-linked SO answer says is the best way from bash scripts (which bin/solr is).

        This patch also renames $unzipCommand to $UNPACK_WAR_CMD, and adds -q to the unzip command, so that it's quiet (like jar xf is).

        Show
        Steve Rowe added a comment - Updated patch. Timothy Potter told me offline that with the original patch, bin/solr healthcheck -c whatever fails when the war has not yet been unpacked. I reproduced: $ bin/solr healthcheck -c testing bin/solr: line 386: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/jar xf: No such file or directory Error: Could not find or load main class org.apache.solr.util.SolrCLI This patch fixes that problem, and also switches from using command -v to hash to check for executables, which the above-linked SO answer says is the best way from bash scripts (which bin/solr is). This patch also renames $unzipCommand to $UNPACK_WAR_CMD , and adds -q to the unzip command, so that it's quiet (like jar xf is).
        Hide
        Steve Rowe added a comment -

        Without the patch I see the same failure on Debian 7.8 - bash version 4.2.37(1)-release (x86_64-pc-linux-gnu).

        The updated patch allows bin/solr to run for me on Debian under bash 4.2.

        Committing shortly.

        Show
        Steve Rowe added a comment - Without the patch I see the same failure on Debian 7.8 - bash version 4.2.37(1)-release (x86_64-pc-linux-gnu) . The updated patch allows bin/solr to run for me on Debian under bash 4.2. Committing shortly.
        Hide
        ASF subversion and git services added a comment -

        Commit 1656133 from Steve Rowe in branch 'dev/trunk'
        [ https://svn.apache.org/r1656133 ]

        SOLR-7067: bin/solr won't run under bash 4.2+

        Show
        ASF subversion and git services added a comment - Commit 1656133 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1656133 ] SOLR-7067 : bin/solr won't run under bash 4.2+
        Hide
        ASF subversion and git services added a comment -

        Commit 1656136 from Steve Rowe in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1656136 ]

        SOLR-7067: bin/solr won't run under bash 4.2+ (merged trunk r1656133)

        Show
        ASF subversion and git services added a comment - Commit 1656136 from Steve Rowe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1656136 ] SOLR-7067 : bin/solr won't run under bash 4.2+ (merged trunk r1656133)
        Hide
        ASF subversion and git services added a comment -

        Commit 1656137 from Steve Rowe in branch 'dev/branches/lucene_solr_5_0'
        [ https://svn.apache.org/r1656137 ]

        SOLR-7067: bin/solr won't run under bash 4.2+ (merged trunk r1656133)

        Show
        ASF subversion and git services added a comment - Commit 1656137 from Steve Rowe in branch 'dev/branches/lucene_solr_5_0' [ https://svn.apache.org/r1656137 ] SOLR-7067 : bin/solr won't run under bash 4.2+ (merged trunk r1656133)
        Hide
        Steve Rowe added a comment -

        Committed to trunk, branch_5x and lucene_solr_5_0.

        Show
        Steve Rowe added a comment - Committed to trunk, branch_5x and lucene_solr_5_0.
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.
        Hide
        Steve Rowe added a comment -

        Reopening to backport to 4.10.4

        Show
        Steve Rowe added a comment - Reopening to backport to 4.10.4
        Hide
        Steve Rowe added a comment -

        Committed to lucene_solr_4_10

        Show
        Steve Rowe added a comment - Committed to lucene_solr_4_10
        Hide
        ASF subversion and git services added a comment -

        Commit 1662612 from Steve Rowe in branch 'dev/branches/lucene_solr_4_10'
        [ https://svn.apache.org/r1662612 ]

        SOLR-7067: bin/solr won't run under bash 4.2+ (merged branch_5x r1656136)

        Show
        ASF subversion and git services added a comment - Commit 1662612 from Steve Rowe in branch 'dev/branches/lucene_solr_4_10' [ https://svn.apache.org/r1662612 ] SOLR-7067 : bin/solr won't run under bash 4.2+ (merged branch_5x r1656136)
        Hide
        Michael McCandless added a comment -

        Bulk close for 4.10.4 release

        Show
        Michael McCandless added a comment - Bulk close for 4.10.4 release

          People

          • Assignee:
            Steve Rowe
            Reporter:
            Steve Rowe
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development