Configuring emacs / slime / swank for clojure with leiningen

Short version: errors when starting Mx slime-connect or Mx clojure-jack-in when using lein swank to start a swank server.

I am using emacs 24.0.50.1 on Ubuntu 10.10. I installed the following packages in emacs from ELPA: clojure -mode, paredit, slime, slime-repl

I installed leiningen from github and added it to the classpath, and then ran lein plugin install swank-clojure 1.3.3 . After that, I created a new directory ~ / tmp /, cd in it and ran: lein new test-project , which seemed to set everything up fine. Then I opened the file / tmp / new -project / project.clj in emacs and changed it to:

 (defproject test-project "1.0.0-SNAPSHOT" :description "Test Project" :dependencies [[org.clojure/clojure "1.2.1"] [org.clojure/clojure-contrib "1.2.0"]] :dev-dependencies [[swank-clojure "1.3.3"]]) 

After that, I returned to the / tmp / new -project folder and ran lein deps , then lein swank to load the dependencies and start the swank server, which gives the result:

 Connection opened on local port 4005. 

Emacs has a problem connecting to the swank server. I tried to open the core.clj file and run Mx slime-connect , which gives an error:

 Symbol function definition is void: define-slime-contrib 

Which makes me think that he either does not see that the running server is working, or there is some kind of configuration that must be made to view the server. I also tried (with the same open file and opening project.clj) Mx clojure-jack-in , which I suppose is trying to run clojure REPL in the project folder, but this gives the following:

 Debugger entered--Lisp error: (error "Could not start swank server: sh: lein: not found ") signal(error ("Could not start swank server: sh: lein: not found\n")) error("Could not start swank server: %s" "sh: lein: not found\n") clojure-jack-in-sentinel(#<process swank> "exited abnormally with code 127\n") 

I followed the instructions of http://matthias-schneider.org/docs/clojure-setup/ for emacs packages and installing lein, and then started following the test configuration instructions from http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html when I'm having trouble connecting Mx slime-connect to open REPL.

Update

deleted ~ / tmp / test-project, deleted emacs and / .emacs.d / elpa / packages, reinstalled emacs, reinstalled clojure -mode and paredit packages copied ~ / .lein to / bin to make sure there are no problems with the loop ( there was no certainty about the need for /.lein or / .lein / bin on the way). Ran /.lein/bin/swank-clojure and then opened emacs, opened project.clj and tried Mx slime-connect , which now asks me for the host (local by default), port (4005 by default), says the connection with swank, gives a message about swank and the slime version is different (y or n) y, then the minibuffers give an error in process filter: Lisp connection closed unexpectedly . In the terminal where I ran /.lein/bin/swank-clojure , the following java error appears:

 exception in read loop java.lang.NumberFormatException: For input string: " a6" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:470) at swank.core.protocol$read_swank_message.invoke(protocol.clj:41) at swank.core.connection$read_from_connection.invoke(connection.clj:59) at swank.core$read_loop.invoke(core.clj:337) at swank.swank$connection_serve$fn__1486$fn__1487.invoke(swank.clj:32) at clojure.lang.AFn.applyToHelper(AFn.java:159) at clojure.lang.AFn.applyTo(AFn.java:151) at clojure.core$apply.invoke(core.clj:540) at swank.swank$connection_serve$fn__1486.doInvoke(swank.clj:29) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.AFn.run(AFn.java:24) at java.lang.Thread.run(Thread.java:636) 

Update: Solved, I had to remove emacs and remove ALL /.emacs.d/, not just the packages in / elpa /. After reinstallation, I received only the clojure-mode package, not slime or slime-repl. Now you can connect to the Mx clojure-jack-in and I'm ready to do some work!

+6
source share
5 answers

you do not need to install slime and slime-repl: they are built into the lein plugin (see inside jar: swank-clojure -1.4.0-SNAPSHOT.jar \ swank \ payload). You only need to install clojure -mode.

In addition, when "reinstalling", be sure to also delete the hidden .emacs.d folder in the $ HOME directory, otherwise it will save your previously loaded Emacs plugins.

Lastly, prefer clojure-jack-in rather than slime-connect - just having slime-connect means you still have SLIME inside Emacs, so you didn't delete it.

+2
source

I wrote a beginner's guide to setting up the Emacs + nREPL client with autocompletion and a pop-up documentation window, since most of the old instructions are not suitable. Available here . May be useful for beginners.

+2
source

No need to install lein swank plugin. You can add dependencies in the project.clj file and just lein swank and Mx slime-connect .

Try with swank-clojure "1.2.1", it works for me.

+1
source

Try the following, which works for me with Emacs 24 on Ubuntu:

  • Install Leiningen. Make sure the directory where you install lein is on $PATH !
  • Install the swank-clojure plugin:

    lein plugin install swank-clojure 1.3.3

  • Create a new project with lein new . Do not add swank-clojure to :dev-dependencies . (You really only need one or the other, a plugin or an entry in :dev-dependencies .)

  • Launch Emacs, making sure it can "see" lein on $PATH , for example. eg:

    PATH=$PATH:/path-to/dir-where/lein-is emacs

    (Use this command to try. For permanent use, you must update $PATH in your .profile file or install lein in a folder that is already in $PATH . In a standard Ubuntu installation, ~/bin should be on $PATH .)

  • Open the file from the project, for example. project.clj and run Mx clojure-jack-in . This should start the Swank server and connect the SLIME REPL to it.

0
source

this happened to me when I cloned a project of another clojure from the old version. their .clj project had:

 :dev-dependencies [[lein-clojars "0.5.0"] [swank-clojure "1.2.1"]] 

This is wrong, I think if you use Mx clojure-jack-in . deleting these lines by running lein deps and working for me.

0
source

Source: https://habr.com/ru/post/899896/


All Articles