Mac下安装leiningen

1.leiningen介绍

leiningen是Clojure下的项目构建工具,相当于Java中的Maven。

leiningen安装

方法一:通过Brew进行安装

这是最简单的一种方式,但是如果你的Mac配置的brew源是国外的,或者一些源没有对应的依赖,则需要进行切换。

怎么切换对应的brew的源呢,见brew 切换国内的源

这里把上方的博客内容一些关键的地方进行引用:

# 替换brew.git:
 cd "$(brew --repo)"
# 中国科大:
 git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
 git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
 cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
 git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
 git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
# 中国科大:
 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
 source ~/.bash_profile
# 清华大学:
 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
 source ~/.bash_profile

# 应用生效:
 brew update

方法二:通过官方仓库向导进行安装

打开官网:https://github.com/technomancy/leiningen

在仓库主页下方我们可以看到Installation,当中有5步,这里翻译出来,粘贴一下

  • 1.确保安装了Java;此时建议使用OpenJDK版本8。
  • 2.从此项目的稳定分支下载Lein脚本
  • 3.将它放在$path。(如果它在路径上,~/bin是一个不错的选择。)
    也就是放在系统变量上,mac上对应也就是~/.zshrc 文件
  • 4.设置该文件可以被执行 (chmod +x ~/bin/lein)
  • 5.Run it.

这里需要注意的是,当运行这个脚本的时候,可能会抛出一些错误:

通过文件下载失败

打开那个Lein脚本,你会发现它请求的是对应的一个jar文件,所以直接在这个命令下进行输出一下 echo LEIN_URL然后通过浏览器进行下载

image.png

手动下载完成之后将jar包放在lein脚本同级目录下的 ./leiningen-2.9.8/self-installs

然后重新执行lein脚本

Error: -classpath requires class path specificatio

这个导致的原因有可能是脚本这一行没有指定正确的classpath,将其进行写为固定值,然后保存进行运行

image.png

验证安装成功

重新打开一个终端,然后输入 lein

提示:image.png

表示已经安装完成

# leiningen 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×