Getting Leiningen & Cygwin Working
Asked Answered
E

6

5

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?

Edithe answered 8/7, 2014 at 14:24 Comment(0)
M
9

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.

Mcgarry answered 8/7, 2014 at 15:46 Comment(7)
@a-webb thanks! I tried a few more things like changing the JAVA_HOME and it only started to work once I changed the LEIN_JAVA_CMD variable using the same value: export LEIN_JAVA_CMD="/cygdrive/c/Program Files/Java/jdk1.8.0_05/bin/java.exe".Edithe
@a-webb: however now it doesn't looks like it is quite "installed" for cygwin. When I start ./lein I get the list of possible arguments but when it starts I see: which: no lein in ([MY-PATH-VAR]). Also, it is not registered such that I can run it from anywhere with: lein (disclaimer: this is my first day with cygwin ;) ) Not sure, but I think I am missing something.Edithe
@Edithe Try the PATH method instead in a fresh shell (so that JAVA_CMD and LEIN_JAVA_CMD are left unset). The second method I described before the edit is more complicated than I realized.Mcgarry
@Edithe Fixed second method now. You do need both LEIN_JAVA_CMD and JAVA_CMD set for that method to launch the sub-processes.Mcgarry
LEIN_JAVA_CMD should be the Cygwin version of the path that the shell will understand, JAVA_CMD the windows version that Java will understand.Mcgarry
None of these work. I still get the same error message.Endocrinology
@AdamArold If you figure out your particular problem, please do post an answer. Unfortunately, I am currently removed from Cygwin and Clojure professionally and don't have time to investigate.Mcgarry
C
2

If you have lein previously installed on Windows and want to reach it from cygwin, then do:

on cmd:

cd C:/Users/%userprofile%/.lein/bin
mklink lein lein.bat

on cygwin:

export CYGWIN=winsymlinks:nativestrict
Clisthenes answered 16/9, 2016 at 8:36 Comment(0)
F
1

I feel your pain. I tried something like this myself several years ago. You have at least two problems. One is getting lein to run as under unix as you noted. There are really two lein scripts - one for unix, the other a batch script for use under windows. Your bigger problem is java.exe - getting the windows java executable to behave as a cygwin shell, and particular the unix lein script running in a cygwin shell, expects is messy and fragile undertaking.

I would strongly recommend either using a clojure ide that supports Windows (perhaps LightTable) or installing a full linux virtual machine with the unix java SDK and doing clojure development in that environment. Ubuntu running on virtualbox is freely available and an option I have used in the past for just this purpose.

Freemasonry answered 8/7, 2014 at 14:48 Comment(0)
G
1

You need to create a symbolic link to the "lein.bat" file.so you use it properly in Cygwin. Open CMD and go to the ".lein" path (cd %userprofile%\.lein\bin) and run this: mklink lein lein.bat

Gar answered 17/2, 2016 at 14:22 Comment(1)
This caused an issue where lein repl was not interactive (the user=> prompt would not accept commands). Works correctly if you run the Linux version of the lein script, as explained in @A. Webb's answer.Embellish
G
0

@a-webb is almost right ,but there are still some steps to complete.First,you will find a folder called “.lein” where you run the lein script in cygwin,go in,copy the folder "self-installs" inside to C:\Users\yourUserName.lein ,then,add C:\Users\yourUserName.lein\bin to the environment variable $Path.

Gilolo answered 28/10, 2015 at 7:4 Comment(1)
lein command still can't works in cygwin ,but it can work in cmdGilolo
G
0

I've found the easiest way is to:

  • Install via the windows binaries and
  • Copy the lein bash script into .lein/bin

Then it should just work in cygwin.

Grillwork answered 6/10, 2017 at 4:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.