6

Short version: errors when running M-x slime-connect or M-x clojure-jack-in when using lein swank to start the swank server.

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

I installed leiningen from github & added it to the classpath, then ran lein plugin install swank-clojure 1.3.3. After that I created a new directory ~/tmp/, cd into it and ran: lein new test-project which seemed to setup everything ok. Then I opened up /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 went back in the /tmp/new-project folder and ran lein deps then lein swank to download the dependencies and start the swank server which gives the output:

Connection opened on local port 4005.

Back in emacs is where I'm having the problem of getting it to connect to the swank server. I've tried opening the core.clj file and running M-x slime-connect which gives the error:

Symbol's function definition is void: define-slime-contrib

Which makes me think it either doesn't see the swank server running or there's some config that needs to be done for it to see the server. I also tried (with the same file open and with project.clj open) M-x clojure-jack-inwhich I assume tries to start the clojure REPL in the project folder but that 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 was following directions from http://matthias-schneider.org/docs/clojure-setup/ for the emacs packages and lein setup, then started following the Test Configuration instructions from http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html once I had problems getting M-x slime-connect to open a REPL.

Update:

deleted ~/tmp/test-project, uninstalled emacs and /.emacs.d/elpa/ packages, reinstalled emacs, reinstalled clojure-mode and paredit packages, copied ~/.lein into /bin to make sure of no path issues (wasn't sure if /.lein or /.lein/bin needed to be in the path). Ran /.lein/bin/swank-clojure and then opened emacs, opened the project.clj, and tried M-x slime-connect, which now asks me for a host (local default), port (4005 default), says connecting to swank, gives a message about swank and slime versions differing (y or n) y, then the minibuffers gives error in process filter: Lisp connection closed unexpectedly. In the terminal where I ran /.lein/bin/swank-clojure the following java error pops up:

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 needed to uninstall emacs and delete ALL of /.emacs.d/, not just the packages in /elpa/. After reinstalling I only got clojure-mode package, not slime or slime-repl. Can now connect with M-x clojure-jack-in and am ready to do some work!

element8
  • 105
  • 2
  • 9

5 Answers5

2

I wrote a beginner's guide for setting up Emacs + nREPL client with auto-complete and documentation popup since most old instructions weren't appropriate. Available here. May be helpful for newcomers.

Tvaroh
  • 6,645
  • 4
  • 51
  • 55
2

you don't need to install slime and slime-repl: they are embedded into lein's plugin (see inside the jar: swank-clojure-1.4.0-SNAPSHOT.jar\swank\payload). You have to install just the clojure-mode.

Also, when "reinstalling", remember to delete also the hidden folder .emacs.d in your $HOME directory, otherwise it will keep your previously downloaded Emacs plugins.

Finally prefer clojure-jack-in, not slime-connect - just having slime-connect means that you are still having a SLIME inside Emacs, so you didn't remove it.

robermann
  • 1,722
  • 10
  • 19
  • Thanks! That did it. I dumped /.emacs.d/ and reinstalled again (before I just deleted the folders in /.emacs.d/elpa/). Then I only reinstalled the clojure-mode package. Now works with `M-x clojure-jack-in`. I guess it had something to do with the slime or slime-repl packages I was downloading. Also still using swank-clojure 1.3.3 and it's working without slime packages so I will avoid 1.4.0-SNAPSHOT unless something else pops up. – element8 Oct 25 '11 at 03:54
1

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

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

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
  • 1
    Changed to "1.2.1" in project.clj, ran `lein deps`, ls shows "1.2.1" in lib/dev/, `lein swank`, & `M-x slime-connect` gives the same error. Thanks for trying though I was just going with newer versions since I wasn't sure if emacs 24 would have problems with older versions. – element8 Oct 23 '11 at 06:32
  • Un install the plugin & try again.. You can refer the Known issues are in swank-clojure github account: https://github.com/technomancy/swank-clojure – Abimaran Kugathasan Oct 23 '11 at 06:39
  • Uninstalled the plugin with `lein plugin uninstall swank-clojure 1.3.3` (~/.lein/plugins is empty now), ran `lein deps` & `lein swank` in the project folder, `M-x slime-connect` and `M-x clojure-jack-in` still give the same errors. Something I noticed now is when running lein swank it gives: `user=> Connection opened on local port 4005 #` instead of the single line in the original post – element8 Oct 23 '11 at 06:57
  • @element8 : Correct! do M-x slime-connect after you get the above message! – Abimaran Kugathasan Oct 23 '11 at 10:01
  • I did, but it still gives the same error messages in the original post. Do you think it might be something with the packages I downloaded from ELPA? – element8 Oct 23 '11 at 18:04
  • So, uninstall the emacs and other packages, I don't recommend installing the package through the lein plugin. Install manually. – Abimaran Kugathasan Oct 24 '11 at 05:57
0

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

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

    lein plugin install swank-clojure 1.3.3

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

  4. Start Emacs, making sure it can "see" lein on the $PATH, e.g. like this:

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

    (Use this command to try it out. For permanent use you should update the $PATH in your .profile file or install lein in a location that's already on the $PATH. In a standard Ubuntu install, ~/bin should be on the $PATH.)

  5. Open a file from the project, e.g. project.clj, and run M-x clojure-jack-in. This should start the Swank server and connect the SLIME REPL to it.

Christian Berg
  • 14,246
  • 9
  • 39
  • 44
  • Thanks, I think I'm closer but still not quite there. I followed your directions and started emacs with `PATH=$PATH:/home/element8/.lein emacs-snapshot`. Once in emacs I opened project.clj in /tmp/test-project, and tried `M-x clojure-jack-in` which gives in the minibuffer: `starting swank...` then `Loading ` something quick, I couldn't read it all but it looked like slime in /.emacs.d/, then gives the same error `Symbol's function definition is void: define-slime-contrib` – element8 Oct 25 '11 at 01:55
  • I also tried copying ~/.lein into /bin and it gives the same error as above, think I'm going to try reinstalling emacs and get the packages again to make sure that isn't the problem. – element8 Oct 25 '11 at 02:03
  • reinstalled emacs, reinstalled the 4 packages i had(clojure-mode, slime, slime-repl, and paredit), there were some warnings when the packages compiled but they compiled, and running `M-x clojure-jack-in` with project.clj open gives the following messages: `Starting swank server... Loading /home/element8/.emacs.d/swank/slime-c3230b2c.elc... error in process filter: eval-buffer: Symbol's function definition is void: define-slime-contrib error in process filter: Symbol's function definition is void: define-slime-contrib` I think my problem is with the slime package in .emacs.d but I'm not sure. – element8 Oct 25 '11 at 02:19
  • looks like I was wrong, removed the slime and slime-repl packages from emacs and the same error occurs, looks like it's coming from /.emacs.d/swank/ which I think it's pulling from swank-clojure 1.3.3 installed in lein. – element8 Oct 25 '11 at 02:43
0

this happened to me when i cloned someone else's clojure project from an older version. their project.clj had:

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

which is incorrect, i think, if you're using M-x clojure-jack-in. removing these lines, running lein deps and jacking in worked for me.

Dustin Getz
  • 21,282
  • 15
  • 82
  • 131