简体   繁体   English

在Windows上使用Gin Bash中的Leiningen

[英]Using Leiningen in Git Bash on Windows

So i installed Leiningen and git on windows. 所以我在窗户上安装了Leiningen和git。 But git bash does not seem to find the lein command because it is based on a .bat file. 但是git bash似乎没有找到lein命令,因为它基于.bat文件。 It works in the windows command line. 它适用于Windows命令行。 Is there any way to get the lein command to work in git bash? 有没有办法让lein命令在git bash中工作?

First, I added the lein.sh script into ~/bin folder. 首先,我将lein.sh脚本添加到〜/ bin文件夹中。 This folder should be added in the path by GitBash itself. 该文件夹应该由GitBash本身添加到路径中。 If it's not in PATH, you can add lein.sh to any folder that is in there or simply add ~/bin to your PATH. 如果它不在PATH中,您可以将lein.sh添加到其中的任何文件夹中,或者只需将〜/ bin添加到PATH中。 Something like: 就像是:

PATH=$PATH:~/bin

You can set the following alias on "~/.bashrc" in your home directory to it easier to call Leiningen: 您可以在主目录中的“〜/ .bashrc”上设置以下别名,以便更轻松地调用Leiningen:

alias lein='lein.bat'

It's working fine with Leiningen 2.6.1 and Git Bash 2.8.0. 它与Leiningen 2.6.1和Git Bash 2.8.0一起运行良好。

If I go into git bash and type echo $PATH I see what seems like the same thing as when I type echo %PATH% from a dos console. 如果我进入git bash并输入echo $PATH我会看到与从dos控制台输入echo %PATH%时的情况相同。

So I alter the Windows Path environment variable so it includes C:\\programs\\lein , which is where lein.bat is. 所以我改变了Windows Path环境变量,因此它包含了C:\\programs\\lein ,这是lein.bat所在的lein.bat

Back into git bash I type lein and get command not found . 回到git bash我输入leincommand not found But if I type lein.bat I can see it is trying to run the file, presumably as if it were a shell script: 但是,如果我键入lein.bat我可以看到它正在尝试运行该文件,大概就像是一个shell脚本:

Chris@CHRIS-XPS ~
$ lein.bat
/c/programs/lein/lein.bat: line 1: @echo: command not found
/c/programs/lein/lein.bat: line 3: setLocal: command not found
/c/programs/lein/lein.bat: line 7: syntax error near unexpected token `('
/c/programs/lein/lein.bat: line 7: `if "%LEIN_VERSION:~-9%" == "-SNAPSHOT" ('

So you will be able to get further by dropping in lein.sh to replace lein.bat . 所以你可以通过放入lein.sh来取代lein.bat Good to start with your own lein.sh that tries to only execute java -jar lein.jar -cp ... (I made that up but it should be possible to piece the correct command together from viewing the batch file (or the shell script)). lein.sh从你自己的lein.sh开始尝试只执行java -jar lein.jar -cp ... (我做了这个但是应该可以通过查看批处理文件(或shell)将正确的命令拼凑在一起脚本))。 In fact if your Windows hosted lein.sh can start any java program, it should also be able to start lein. 事实上,如果你的Windows托管 lein.sh可以启动任何java程序,它也应该能够启动lein。

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

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