简体   繁体   English

让Leiningen和Cygwin工作

[英]Getting Leiningen & Cygwin Working

I am trying to get Leiningen and Cygwin working together. 我想让Leiningen和Cygwin一起工作。

One of the problems I think I have is that I have Java installed in "C:\\Program Files\\Java..." directory. 我认为我遇到的一个问题是我在“C:\\ Program Files \\ Java ...”目录中安装了Java。 The space appears to be causing issues. 这个空间似乎引起了问题。

When I try to run the lein script in Cygwin, I am getting the following error: 当我尝试在Cygwin中运行lein脚本时,我收到以下错误:

./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: 所以我改变了第325行:

"$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. lein脚本似乎正在为Cygwin正确配置Leiningen,但我无法让它工作。

Note that I previously installed Leiningen outside of Cygwin (I was running it in Windows' normal shell). 请注意,我之前 Cygwin 之外安装了Leiningen(我在Windows的普通shell中运行它)。

What could be wrong with my setup, any ideas? 我的设置,任何想法可能有什么问题?

I use Leiningen via Cygwin with no problems. 我通过Cygwin使用Leiningen没有任何问题。

Start over 重来

Start over with a fresh copy of the lein script. 重新开始使用lein脚本的新副本。 There should be no need to edit it. 不需要编辑它。

Set your PATH to include java 将PATH设置为包含java

The easiest solution is to set your path in ~/.profile to include the path to Java's bin directory. 最简单的解决方案是在~/.profile设置路径以包含Java的bin目录的路径。 Lein will then find java on the path and you'll have access to java and its related tools in your shell. 然后Lein会在路径上找到java,你可以在shell中访问java及其相关工具。

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

Restart your shell or source ~/.profile . 重新启动shell或source ~/.profile Verify that which java finds java command. 验证which java找到了java命令。 And run java to verify you get the help output. 并运行java以验证您获得帮助输出。

And/or explicitly set the LEIN_JAVA_CMD and JAVA_CMD variables 和/或显式设置LEIN_JAVA_CMDJAVA_CMD变量

Alternatively, set the LEIN_JAVA_CMD and JAVA_CMD variables used by lein in your ~/.profile 或者,在~/.profile设置LEIN_JAVA_CMD使用的LEIN_JAVA_CMDJAVA_CMD变量

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 . 重新启动shell或source ~/.profile

Note: You can also set a separate LEIN_JVM_OPTS and JVM_OPTS if desired, but this should not be necessary. 注意:如果需要,您还可以设置单独的LEIN_JVM_OPTSJVM_OPTS ,但这不是必需的。

If you have lein previously installed on Windows and want to reach it from cygwin, then do: 如果您以前在Windows上安装了lein并希望从cygwin访问它,请执行以下操作:

on cmd: 在cmd上:

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

on cygwin: 在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. 正如你所指出的那样,一个是让lein像unix一样运行。 There are really two lein scripts - one for unix, the other a batch script for use under windows. 实际上有两个lein脚本 - 一个用于unix,另一个用于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. 你的更大的问题是java.exe - 让windows java可执行文件表现为cygwin shell,特别是在cygwin shell中运行的unix lein脚本,预计是凌乱和脆弱的事。

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. 我强烈建议使用支持Windows(可能是LightTable)的clojure ide,或者使用unix java SDK安装完整的Linux虚拟机,并在该环境中进行clojure开发。 Ubuntu running on virtualbox is freely available and an option I have used in the past for just this purpose. 在virtualbox上运行的Ubuntu是免费提供的,并且我过去使用的选项就是为了这个目的。

You need to create a symbolic link to the "lein.bat" file.so you use it properly in Cygwin. 您需要创建一个指向“lein.bat”文件的符号链接。因此您可以在Cygwin中正确使用它。 Open CMD and go to the ".lein" path ( cd %userprofile%\\.lein\\bin ) and run this: mklink lein lein.bat 打开CMD并转到“.lein”路径( cd %userprofile%\\.lein\\bin )并运行: mklink lein lein.bat

@ a-webb几乎是正确的,但仍有一些步骤要完成。首先,你会找到一个名为“.lein”的文件夹,你在cygwin中运行lein脚本,进入,复制文件夹“self-installs”里面到C:\\ Users \\ yourUserName.lein,然后将C:\\ Users \\ yourUserName.lein \\ bin添加到环境变量$ Path。

I've found the easiest way is to: 我发现最简单的方法是:

  • Install via the windows binaries and 通过Windows二进制文件安装和
  • Copy the lein bash script into .lein/bin 将lein bash脚本复制到.lein / bin

Then it should just work in cygwin. 然后它应该在cygwin中工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM