Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing Clojure in Emacs with `cider-jack-in`

I'm trying to run Clojure emacs with cider package installed. I use Emacs 24.5.1 on Mac OS X 10.10.4.

I downloaded lein script and copied the script in ~/Dropbox/bin. I checked with lein repl that Clojure works fine.

cider package is installed with M-x 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.

However, when I started emacs and run M-x cider-jack-in, I have this error message:

enter image description here

When I started lein repl and executed M-x cider-connect (http://xahlee.info/clojure/clojure_emacs_cider.html), I can have the cider-repl running in Emacs.

enter image description here

What might be wrong?

like image 985
prosseek Avatar asked Dec 02 '22 16:12

prosseek


1 Answers

The quickest fix was to symbolically link lein to the path where Emacs can find it. 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.

cider - https://github.com/clojure-emacs/cider

Installation

  • Download lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
    • I copied the file ~/Dropbox/bin after making it executable.
  • It looks like that /usr/local/bin is not the path that Emacs finds the binary automatically, so I had to set it up.

    • Run sudo ln -s ~/Dropbox/bin/lein /usr/local/bin/lein
    • Update ~/.emacs.d/init.el to specify the location of lein script:
      • (add-to-list 'exec-path "/usr/local/bin")
  • Update ~/.lein/profiles.clj

    • Installation of cider-nrepl
    • {:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]]}}
    • run lein deps

Errors and solutions

  • If error The lein executable (specified bycider-lein-command' or cider-boot-command') isn't on your exec-path occurs:

    • make the symbolic link, and update the init.el as is explained.
  • If error "Symbol's function definition is void: clojure-project-dir" occurs, it's because of the package version mismatch.

    • http://www.braveclojure.com/using-emacs-with-clojure/
    • delete the old packages in ~/emacs.d/elpa
      • clojure-mode
      • cider-*
    • Then, run package-install in Emacs
      • clojure-mode
      • cider

Now, all the warnings are gone.

enter image description here

References

  • Can't launch `lein` REPL in Emacs
  • Executing Clojure in Emacs with `cider-jack-in`
  • cider - https://github.com/clojure-emacs/cider

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?. This is the message from the 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.

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
like image 189
prosseek Avatar answered Dec 20 '22 03:12

prosseek