How to update cider in 'brave clojure' bootstrapped emacs - emacs

I have (except for some additions such as company-mode my emacs 24.5 configured as recommended in the chapter of clojure for the brave and true.
Unfortunately I ran into a problem where I tried to work through some alice in wonderland clojure katas and the REPL would not fire up in the correct namespace. I could switch to the namespace with C-c M-n and the REPL showed the namespace, however any evaluation after that gave me an error „namespace does not exist“.
I tried to update cider-nrepl (simply by changing it in ~/.lein/profiles.clj, but then it gave me an error that Cider and Cider-nREPL version numbers were incompatible. I tried to update with a simple package-install cinder which also did not work but gave me this warnings along the lines of the function cider-find-var is not known and functions being called with the wrong number of arguments.
How do I keep the packages up to date? Is my namespace issue even related to this?

Your namespace issue sounds like a different problem. This happens if you have a namespace in a file, and that file is not loaded automatically when cider starts.
You can switch the repl to that name, though none of the contents will have been loaded until you load the file by pressing Ctrl-cCtrl-k. If you add a require in core.clj (or whatever your project uses as it's start namespace) that requires the namespace in question, than that namespace will get loaded when you start cider.
on to your cider nrepl version matching problem. This can happen when a new verion of cider is released and you do something in emacs that updates the packages. then your cider version gets ahead of the nrepl version. I have had the most pleasant experience by always setting the cider-nrepl version in ~/.lein/profiles.clj to the version listed at the top of the screen when you start cider.
Update: cider nrepl config is no longer required!
The world has improved and you no longer need to set anything in ~/.lein/profiles.clj. You should remove all cider and nrepl references from that file and then install the latest version of cider.el and all this stuff will start working. Specifically cider.el now ads the proper dependency to lein when you run cider-jack-in automatically. So if you have the latest version, and start lein through cider then you no longer need to do any special stuff.

Related

Why is cider-jack-in hanging in emacs

I'm working through the following tutorial on Clojure. I've just installed both Emacs and Leiningen. If invoked separately, both work. However, when I am trying to invoke cider-jack-in, as described in the tutorial:
Using Emacs, open the file clojure-noob/src/clojure_noob/core.clj,
which you created in Chapter 1. Next, use M-x cider-jack-in. This
starts the REPL and creates a new buffer where you can interact with
it.
that hangs forever after the last message:
Starting nREPL server via lein repl :headless...
You can run the command `cider-jack-in' with C-c M-j
Starting nREPL server via lein repl :headless...
What am I doing wrong?
Edit: To solve the problem, I upgraded leiningen from 1.7 (that's what apt-get installed) to 2.6.1.
Recently cider changed so you no longer need to add things to ~/.lein/profiles.clj to install cider-nrepl and clj-refactor. Cider will take care of that now. You should remove that part from your config.
In general for these situations it help to run lein from the command line first and make sure it can actually get the projects dependencies. Most of the times it's sitting there downloading a jar file at 3 bytes per second and not actually stalled. Other times it's failing with SSL/TLS certificate validation problems.

Emacs/CIDER Error

I'm trying to do some Clojure development using Emacs and cider, and following this tutorial. I've gotten to the point where I need to do M-x cider-jack-in, which is supposed to start a *cider-repl* buffer, but instead gives me the error
error in process filter: Symbol's function definition is void: clojure-mode-variables
I'm running emacs 24.3.1, cider-20150412.827 (out of melpa), Leiningen 2.3.4, and I get the error whether I specify [cider/cider-repl "0.7.0"] or [cider/cider-repl "0.8.2"]. I'm able to successfully run lein run on the project I'm trying to edit.
Any ideas what I'm doing wrong?
You're using an outdated version of clojure-mode. Update to a recent version (e.g. the latest) and everything should be fine. Btw, you should also use [cider/cider-nrepl "0.9.0-SNAPSHOT"] together with CIDER from MELPA.

Can't get Cider working

Last month someone helped me get Cider working on a Clojure project. I loved the functionality, particularly M-., cider-jump-to-var. But since then I haven't been able to replicate the correct behavior, either in the original project or in a new one, and the person who helped set me up originally is no longer available.
In the original project, which I still have checked out, there's a line
[cider/cider-nrepl "0.7.0"]
in the :dependencies section of my project.clj. When I add such a line to my new project, then run lein repl and cider-connect, I get this message:
; CIDER 0.8.0alpha (package: 20141006.507) (Java nil, Clojure 1.6.0, nREPL 0.2.3)
WARNING: The following required nREPL ops are not supported:
classpath complete info inspect-start inspect-refresh inspect-pop inspect-push inspect-reset macroexpand ns-list ns-vars resource stacktrace toggle-trace undef
Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER
WARNING: CIDER's version (0.8.0-snapshot) does not match cider-nrepl's version (0.7.0)
Sure enough, when I to jump to the definition of a symbol (say first), I get:
cider-ensure-op-supported: Can't find nREPL middleware providing op "info". Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER
Oddly, I get the same error when I change the version of cider/cider-nrepl to "0.8.0-SNAPSHOT" in project.clj.
But then I notice on the cider-nrepl Github page that the cider/cider-nrepl line is supposed to be in :plugins, not :dependencies. It definitely wasn't in my original project, but it still worked somehow. Fine, so I move it to :plugins in my new project. This time the nrepl process starts up with no errors, but when I try to jump to the definition of, again, say, first, I get:
Symbol first not resolved
Now if I try downgrading back to 0.7.0, I get a shorter message when I start up cider:
WARNING: The following required nREPL ops are not supported:
ns-list ns-vars undef
Please, install (or update) cider-nrepl 0.8.0-snapshot and restart CIDER
WARNING: CIDER's version (0.8.0-snapshot) does not match cider-nrepl's version (0.7.0)
...but I get the same "Symbol first not resolved" as before.
This is really frustrating. I vaguely recall some kind of version mismatch message when I worked on my original project, and the jump-to-definition feature still worked. Now I can't get it working for the life of me. Any assistance would be immensely appreciated.
EDITED TO ADD:
Before embarking on the exploration described above, I deleted and re-installed Cider from my packages list. I also deleted ~/.m2/repository/cider between each step.
This morning, I had Cider version 20141006.507. An update was available, so that I now have version 20141007.452. The command cider-version returns just CIDER 0.8.0-snapshot. With [cider/cider-nrepl "0.8.0-SNAPSHOT"] in the :plugins section of my project.clj, I still get Symbol <whatever> not resolved no matter which symbol I try.
You are most likely installing the CIDER package in Emacs from the MELPA repository which means you are installing the latest CIDER snapshot package which requires the [cider/cider-nrepl "0.8.0-SNAPSHOT"] middleware in your project.clj to function correctly.
Since you are using the CIDER snapshot package you can also not use the 0.7.0 CIDER middleware.
When you launch a repl using M-x cider-jack-in or from the command line using lein repl, the latest CIDER middleware is checked for and downloaded (by default, daily) by Leiningen prior to launching the repl.
This means that your middleware snapshot may become out of sync with your Emacs CIDER package version since by default you will have the Emacs CIDER package snapshot that was installed at the time you manually installed it.
In order to bring the middleware and Emacs CIDER package back into sync you should install the latest CIDER Emacs package via M-x package-list-packages and select the cider package for installation.
You should then restart Emacs and run M-x cider-version and confirm that you get the following (as of today) in Messages:
CIDER 0.8.0snapshot (package: 20141007.13)
cider-jump-to-var and all other CIDER functionality should then work.
So apparently the main bit I was missing, which I stumbled upon accidentally, was that before M-. will work, I needed to go up and evaluate the file's initial ns form with C-xC-e (cider-eval-last-sexp).
Occasionally I'll get some unhelpful error message when trying to jump to a definition, like "Wrong type argument: arrayp", but it works often enough to be usable.
Suggestions for how to improve this process would be welcome.

Unable to evaluate form in nrepl + emacs

I have installed the nrepl, clojure-mode and starter-kit-lisp packages. I am able to start the nrepl by opening my .clj file and then M-x nrepl-jack-in.
However when I evaluate any form in my .clj file by C-x C-e, I get the following message:
inferior-lisp-proc: No Lisp subprocess; see variable `inferior-lisp-buffer'
How do I get it right?
I have had this problem a number of times. In all cases, it has been because while nrepl has started, the nrepl minor mode has not been enabled in the clj buffer. As a result, any evaluation attempts fail with this error.
There should be a "nrepl" menu item. If there isn't, this may be your problem. M-x nrepl-enable-on-existing-buffers should fix it.
I had this problem for a while, and now it appears to have gone away; you might want to try installing clojure-mode and nrepl afresh.
Are you sure M-x nrepl-jack-in worked? If it did, you should be prompted with a repl in emacs, like so:
nrepl requires leiningen 2, so make sure that you use the right version in your project and that the nrepl plugin is properly installed.
Also make sure that the major mode when editing your .clj file is clojure-mode.
You might want to post a screenshot to make it easier to spot the problem.

org mode refile error

Since some time (but I didn't change anything in .emacs), I have some errors with emacs's behaviour :
Remember mode will not kill the temporary buffer on "Ctl-C Ctl-C"
Orgmode will not refile any entry
Both operations complain with error "Not bookmark format"
I restored an old .emacs to make sure that I didn't mess it up but the error persists.
Where can I investigate to find out the problem ?
I have Emacs 24.2.1 since end of august.
The built in orgmode version is 7.8.11 (I see 7.9.2 is out ...)
It's always best to start debugging problems such as this by seeing if the problem still happens when you ignore your init file altogether - try starting emacs with --no-init-file and seeing if you still get the problem. If you don't then it's clearly something in your init file.
You can also get odd behaviour if you've got a local install of Org-mode in addition to the one bundled with Emacs itself - eg if you pull in a newer one through ELPA. If you have a local install through ELPA then you can try uninstalling the Org-mode package and trying again using the built-in Org-mode.
I have something similar to the following in my init file to make it switch to the ELPA-installed Org-mode to avoid such problems (this variant is untested so forgive me if it's not quite right):
(package-initialize) ; load and initialise ELPA-installed packages
(org-reload) ; restart Org-mode with the ELPA package
I filed a bug to the emacs team and they found out that the error comes from a corrupted bookmark file.
I removed my ~/.emacs.d/bookmark file (it was empty) and everything is fine now.