Getting Leiningen & Cygwin Working

痴心易碎 提交于 2019-12-04 08:08:37

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.

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

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.

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

@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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!