Groovy bootstrap error using GIT BASH on Windows 7
cygwin, git, groovy, unix
Solution
The problem is in the script from Groovy. The script is not quoting the env variable GROOVY_HOME properly in all the right places. The spaces in the path represented by GROOVY_HOME, in my case "Program Files (x86)" has 2 spaces, are being interpreted as delimiters and causing the path to be parsed out as more than 1 argument. To fix it, change the definition of the windows environment variable GROOVY_HOME to use the tilde version of the path. Edit your environment variable GROOVY_HOME (on Vista, start/right-click computer/properties/advanced system settings/environment variables/either user or system, mine was system) and set to c:/Progra~2/Groovy/Groovy-2.1.3. When you start your Git, MinGW or CygWin shell, you won't have the spaces and should not get any errors.
Problem
I am calling a git hook to pre-commit. This triggers a call to a groovy script and does so in a manner that allows for remote debugging of the hook execution. Like so: ``` #!/usr/bin/env groovy groovy -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8085,suspend=y "C:\Users\.......hooks\PreCommit.groovy" ``` when I trigger the hook with the use of 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 take a quick look at the startGroovy file I see the following unclear 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 the groovy bootstrap? my windows 7 has it env variable GROOVY_HOME correctly pointing to: C:\program file (x86)\Groovy\Groovy-2.1.0