Search code examples
clojurecygwinleiningen

Getting Leiningen & Cygwin Working


I am trying to get Leiningen and Cygwin working together.

One of the problems I think I have is that I have Java installed in "C:\Program Files\Java..." directory. The space appears to be causing issues.

When I try to run the lein script in Cygwin, I am getting the following error:

./lein: line 325: C:\Program Files\Java\jdk1.8.0_05\bin\java.exe : command not found

Then I thought the issue was the space. So I changed line 325 from:

"$LEIN_JAVA_CMD" \

to (for testing purposes):

"$'C:\\\Program Files\\\Java\\\jdk1.8.0_05\\\bin\\\java.exe'" \

But, I am still getting this error:

./lein: line 325: $'C:\\Program Files\\Java\\jdk1.8.0_05\\bin\\java.exe' : commande introuvable

However, this file clearly exists:

Owner@Owner-PC ~
$ ls -alh $'C:\\Program Files\\Java\\jdk1.8.0_05\\bin\\java.exe'
-rwxr-xr-x 1 Owner None 187K  8 mai   15:39 C:\Program Files\Java\jdk1.8.0_05\bin\java.exe

The lein script appears to be properly configuring Leiningen for Cygwin, however I can't get it to work.

Note that I previously installed Leiningen outside of Cygwin (I was running it in Windows' normal shell).

What could be wrong with my setup, any ideas?


Solution

  • I use Leiningen via Cygwin with no problems.

    Start over

    Start over with a fresh copy of the lein script. There should be no need to edit it.

    Set your PATH to include java

    The easiest solution is to set your path in ~/.profile to include the path to Java's bin directory. Lein will then find java on the path and you'll have access to java and its related tools in your shell.

    export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_05/"
    export PATH="${JAVA_HOME}/bin/:${PATH}"
    

    Restart your shell or source ~/.profile. Verify that which java finds java command. And run java to verify you get the help output.

    And/or explicitly set the LEIN_JAVA_CMD and JAVA_CMD variables

    Alternatively, set the LEIN_JAVA_CMD and JAVA_CMD variables used by lein in your ~/.profile

    export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.8.0_05/"
    export LEIN_JAVA_CMD="${JAVA_HOME}/bin/java"
    export JAVA_CMD=`cygpath -w "${LEIN_JAVA_CMD}"`
    

    Restart your shell or source ~/.profile.

    Note: You can also set a separate LEIN_JVM_OPTS and JVM_OPTS if desired, but this should not be necessary.