Groovy bootstrap error with GIT BASH on Windows 7

I am calling git hook to pre-commit. This calls the groovy script and does it in a way that allows you to remotely debug hook execution. For example:

#!/usr/bin/env groovy
groovy -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8085,suspend=y "C:\Users\.......hooks\PreCommit.groovy"

      

when i run the hook using git BASH i see the following error:

/c/Program Files (x86)/Groovy/Groovy-2.1.0/bin/startGroovy: line 96: [: too many arguments org.codehaus......: startup failed: .... expected EOF, found ':' @ line 3 column 35]

      

when I quickly look at the startGroovy file I see the following fuzzy code where line 96 is the if condition with groovy home:

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
  [ -n "$GROOVY_HOME" ] && GROOVY_HOME=`cygpath --unix "$GROOVY_HOME"`
  [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
  [ -n "$CP" ] && CP=`cygpath --path --unix "$CP"`
else
  if [ -n "$GROOVY_HOME" -a `expr "$GROOVY_HOME":'\/$'` ] ; then
      GROOVY_HOME=`echo $GROOVY_HOME | sed -e 's/\/$//'`
  fi
fi

      

Is this a bug in groovy bootstrap? my windows 7 have env variable GROOVY_HOME pointing correctly to: C: \ program file (x86) \ Groovy \ Groovy-2.1.0

+3


source to share


2 answers


The problem is a script from Groovy. The script doesn't reference the env variable GROOVY_HOME correctly in all the correct places. The spaces in the path represented by GROOVY_HOME, in my case "Program Files (x86)" have 2 spaces, are interpreted as delimiters and cause the path to be parsed as more than one argument. To fix this, change the definition of the Windows environment variable GROOVY_HOME to use the tilde version of the path. Edit the GROOVY_HOME environment variable (on Vista, start / right click computer / properties / advanced system settings / environment variables / user or system, my system) and set c: / Progra ~ 2 / Groovy / Groovy- 2.1.3. When you run your Git, MinGW, or CygWin shell, you will have no spaces and no errors should occur.



+4


source


The cygpath command is missing from Git Bash, which only implements a stripped-down version of cgywin. One solution is to use a full cygwin install for git, but it's probably like making your own .bashrc with unix-style names:

# Check to see what the DOS directories are
echo GROOVY_HOME=$GROOVY_HOME
echo JAVACMD=$JAVACMD
echo JAVA_HOME=$JAVA_HOME
echo CP=$CP

# Add the directories you found to .bashrc in a unix style
cat - >>~.bashrc
export GROOVY_HOME='/c/program file (x86)/Groovy/Groovy-2.1.0'
export JAVACMD="..."
export JAVA_HOME="/c/Program files/Java/jre7/bin/java"
export CP= "..."

      



Please change the paths as needed. You can edit .bashrc using notepad ++ or another editor instead of using cat. Remember that cat is terminated with Control-D in Bash, whereas DOS copy file.txt uses Control-Z. By placing these variables in .bashrc, they won't interfere with your DOS environment variables.

+1


source







All Articles