简体   繁体   English

用`cider-jack-in`在Emacs中执行Clojure

[英]Executing Clojure in Emacs with `cider-jack-in`

I'm trying to run Clojure emacs with cider package installed. 我正在尝试运行安装了苹果酒包的Clojure emacs。 I use Emacs 24.5.1 on Mac OS X 10.10.4. 我在Mac OS X 10.10.4上使用Emacs 24.5.1。

I downloaded lein script and copied the script in ~/Dropbox/bin. 我下载了lein脚本并将脚本复制到〜/ Dropbox / bin中。 I checked with lein repl that Clojure works fine. 我用lein repl检查过Clojure工作正常。

cider package is installed with Mx package-install . 苹果包用Mx package-install I edited the ~/.emacs.d/init.el to specify the lein script: (add-to-list 'exec-path "~/Dropbox/bin") with the hint from Can't launch `lein` REPL in Emacs . 我编辑了~/.emacs.d/init.el来指定lein脚本:( (add-to-list 'exec-path "~/Dropbox/bin") list'exec (add-to-list 'exec-path "~/Dropbox/bin") ,提示来自无法启动`lein` REPL in Emacs

However, when I started emacs and run Mx cider-jack-in , I have this error message: 但是,当我启动emacs并运行Mx cider-jack-in ,我收到以下错误消息:

在此输入图像描述

When I started lein repl and executed Mx cider-connect ( http://xahlee.info/clojure/clojure_emacs_cider.html ), I can have the cider-repl running in Emacs. 当我开始lein repl并执行Mx cider-connecthttp://xahlee.info/clojure/clojure_emacs_cider.html )时,我可以在Emacs中运行cider-repl。

在此输入图像描述

What might be wrong? 可能有什么问题?

The quickest fix was to symbolically link lein to the path where Emacs can find it. 最快的解决方案是将lein象征性地链接到Emacs可以找到它的路径。 This line of code fixed the issue. 这行代码解决了这个问题。

sudo ln -s ~/Dropbox/bin/lein /usr/local/bin/lein

I summarized the steps to install the cider package for running Clojure on emacs without any errors or warnings. 我总结了在emacs上安装用于运行Clojure的cider包的步骤,没有任何错误或警告。

cider - https://github.com/clojure-emacs/cider 苹果酒 - https://github.com/clojure-emacs/cider

Installation 安装

  • Download lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein 下载lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
    • I copied the file ~/Dropbox/bin after making it executable. 我将文件〜/ Dropbox / bin复制后使其可执行。
  • It looks like that /usr/local/bin is not the path that Emacs finds the binary automatically, so I had to set it up. 看起来/ usr / local / bin不是Emacs自动找到二进制文件的路径,所以我不得不进行设置。

    • Run sudo ln -s ~/Dropbox/bin/lein /usr/local/bin/lein 运行sudo ln -s ~/Dropbox/bin/lein /usr/local/bin/lein
    • Update ~/.emacs.d/init.el to specify the location of lein script: 更新~/.emacs.d/init.el以指定lein脚本的位置:
      • (add-to-list 'exec-path "/usr/local/bin")
  • Update ~/.lein/profiles.clj 更新~/.lein/profiles.clj

Errors and solutions 错误和解决方案

  • If error The lein executable (specified by cider-lein-command' or cider-boot-command') isn't on your exec-path occurs: 如果错误The lein executable (specified by cider-lein-command'或cider-boot-command') isn't on your exec-path

    • make the symbolic link, and update the init.el as is explained. 制作符号链接,并按说明更新init.el
  • If error "Symbol's function definition is void: clojure-project-dir" occurs, it's because of the package version mismatch. 如果出现错误“符号的函数定义无效:clojure-project-dir”,则是因为包版本不匹配。

Now, all the warnings are gone. 现在,所有的警告都消失了。

在此输入图像描述

References 参考

Added 添加

For Mac OS X, brew install leiningen can install the lein, but this caused an issue as in How to upgrade nrepl version of leiningen? 对于Mac OS X, brew install leiningen可以安装lein,但这引起了如何升级leiningen的nrepl版本的问题? . This is the message from the lein brew. 这是lein brew的消息。

nREPL server started on port 61216 on host 127.0.0.1 - nrepl://127.0.0.1:61216
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14

I had to use the lein from the lein site to get the correct version of tools. 我不得不使用lein网站的lein来获得正确版本的工具。

Retrieving org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
nREPL server started on port 61279 on host 127.0.0.1 - nrepl://127.0.0.1:61279
REPL-y 0.3.7, nREPL 0.2.7
Clojure 1.7.0

Another easy solution is to just use homebrew. 另一个简单的解决方案就是使用自制软件。 While homebrew is overkill just for installing lein, if you already use it, then all you need to do is run 虽然自制软件只是用于安装lein,但如果你已经使用它,那么你需要做的只是运行

brew update
brew install leiningen

and your done. 你做完了 I use homebrew to install emacs and some other useful apps, so I already have it on my system. 我使用自制软件来安装emacs和其他一些有用的应用程序,所以我已经在我的系统上安装了它。

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

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