I just ran "lein new compojure-app guestbook" following the book "Web Development with Clojure". In one step the book is connecting to my Clojure project with light table. However when I try this I get the following error that makes no sense to me.
Here is the error I'm getting
Your Error
For the search engines, here is a copy of the pertinent part of your error:
Error loading lighttable.nrepl.handler: java.lang.RuntimeException: Unable to resolve var: reader/*alias-map* in this context
The Cause
Lighttable has upgraded to using a newer tools.reader.
I found two resources:
An applicable github issue that you might find helpful.
A forum thread covering the question (mentioned in the github issue above).
The Summarized Solution
Several people have solved this by simply running lein clean in their project directory.
If lein clean does not solve it for you, then here is the extended solution from the forum:
In project.clj. Replace
[compojure “1.1.6”]
with
[compojure “1.1.6” :exclusions [org.clojure/tools.reader]]
and add to the :dependencies list
[org.clojure/tools.reader “0.7.10”]
The reason seems to be that LightTable expects this version of
tools.reader, but Compojure brings in version 0.7.3
After employing this solution, you may wish to run lein clean again.
Related
This is asking for help regarding the same question as How to change Clojure or Lein's Clojure default version?
but is not an answer to that question. Should I have nevertheless have written it as an answer under that thread?
Specifying a Clojure version to be used when the "(lein repl)" command is issued outside of a project directory seems to be a natural thing to want. Of course there may be good design reasons for not allowing it, but do you think an error message like the following,
to be displayed when Leiningen detects that the ~/.lein/profiles.clj (or other relevant profile files) specify a different Clojure version from the one hard coded into Leiningen,
would be a good idea?
"specifying the Clojure version to be used with certain software, such as tools.nrepl and clojure-complete, is only allowed when this command is issued within a project directory"
A lot of people apparently have spent a lot of time on Stack Overflow trying to find out how to do this.
References:
"Updating ~/.lein/profiles.clj to {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0"]]}} does not seem to work. – Petrus Theron Jan 10 2018 at 9:05" How do you change Clojure version in Leiningen and LightTable?
"I asked technomancy on IRC just now. He said: "REPL's outside projects are hard coded to lein's version of clojure". – David J. Feb 24 '14 at 19:52" How to change Clojure or Lein's Clojure default version?
"this ^:displace trick will not work with tools.nrepl or clojure-complete." https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
How to upgrade nrepl version of leiningen?
I think you may try to declare different profiles in your project.clj where each of them has its own Clojure version. For example:
:profiles
{;; :default [:base :system :user :provided :dev]
:server-jvm {:jvm-opts ^:replace ["-server"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}}
Now that, when running any Lein command, specify a profile as follows:
lein with-profile 1.7 repl
The REPL session of Clojure 1.7 should start.
I grabbed that fragment from carmine sources. The official Lein profiles manual also has the same example.
See an error message: error in process sentinel: Could not start nREPL server: That’s not a task. Use "lein help" to list all tasks.
In the *Messages* buffer, the full form of the error is:
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: That’s not a task. Use "lein help" to list all tasks.
M-x cider-version shows
CIDER 0.15.0snapshot (package: 20170525.255)
Tried fiddling around with ~/.lein/profiles.clj to explicitly add in
{:user {:plugins [[cider/cider-nrepl "0.15.0snapshot"]]}}`
... but that didn't change anything.
(getting back to Clojure after a while with a "fresh" install (Emacs, clojure-mode, cider, etc. so might have missed some small environment setup step, just don't know what that is!)
Turns out the incompatibility was not with the nRepl middleware, but with Leiningen itself.
Once I uninstalled the version I had installed using apt-get, and self-installed using the downloaded script, and made sure this new version was what which lein led to, this problem went away.
More details: Running cider-jack-in was triggering a call to lein update-in with further arguments, but the version of Leiningen I had simply didn't show update-in as one of the options when I ran lein help.
When I add :repl-options {:init (print "x..")} to ~/.lein/profiles.clj it does what it should on every repl start-up. however, when I add the same to my local project.clj, I receive this error:
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(/tmp/form-init5885833654225579206.clj:1:886)
I'm using leiningen 2.5.3
I've stumbled across this issue as well - I tried to use multiple profiles, each with its own :repl-options.
The issue is that Leiningen doesn't merge `:init: correctly. You can refer to this issue for more details.
Unfortunately, I couldn't find any fix that would work for me. And the issue itself won't be fixed till Leiningen 3.0.
I experience the following error:
CompilerException java.lang.RuntimeException: No such var: user/help, compiling:(/private/var/folders/xy/8l2mmnsj0gv3myj72y0s2kmr0000gn/T/form-init6632573911186472967.clj:1:10884)
#<Namespace user>
Error loading namespace; falling back to user
This only happens in this one project. The project happily compiles to uberjar, and lein run works just fine, it's only the repl that doesn't work.
Anyone have any idea what this could be about?
The entire project is available at https://github.com/Skinney/coc-helper
I stumbled upon this question because I had the same problem. I have opened an issue for that problem, with minimal reproducing project and workaround, on the Leiningen github project.
Since the OP has apparently already solved the problem, here is the TL;DR for anyone else arriving here: the problem is that you require :as user in the main namespace. Changing the alias solves the problem, as the OP has done in this commit.
I'm a clojure noob trying to get emacs & slime set up. There doesn't seem to be one true way to do this, so I've followed a few blog posts and the swank-clojure and leiningen READMEs.
Mostly it works. My problem is that if I try to select restart 0 [QUIT] from a backtrace, I get
'error in process filter: Wrong number of arguments: nil, 0'
(I also see a warning on 'M-x slime-connect' about slime and swank being mismatched versions, but Googling suggests this is expected).
This is Debian Lenny. I got slime via 'git clone git://git.boinkor.net/slime.git'.
Clojure and clojure-contrib are 1.2.0, and swank-clojure is 1.2.1.
Anyone seen this? Alternatively, is there an up-to-date list of compatible versions of all the pieces? Many thanks.
Edit:
Looks like it is probably this issue. I followed the same blog post as the OP in that thread.
Edit:
Yes. Getting slime and slime-repl packages using ELPA fixed it.
Don't get slime via git, but use ELPA. See the links in my edits to the question.
the clojure ecosystem has changed a lot over this last year so many of the most linked tutorials sort of do things the hard way. you dont really need to build clojure/contrib and install it anymore. both Maven2 and leinengen do this ver well for you.
you may be able to get up and clojureing just by installing lein (from the tutorial) and then making a new project. this is enough to keep me happy even on my larger projects. you dont really need to install clojure system wide.
from a (ubuntu-10.10) system that has never seen clojure before i run:
dev:~$ lein new foo
Created new project in: foo
dev:~$ cd foo
dev:~/foo$ ls
project.clj README src test
dev:~/foo$ lein repl
Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
Downloading: org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.pom from central
Downloading: org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.pom from clojure
Transferring 4K from clojure
Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.jar from central
Downloading: org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.jar from central
Downloading: org/clojure/clojure-contrib/1.2.0/clojure-contrib-1.2.0.jar from clojure
Transferring 466K from clojure
Copying 2 files to /home/arthur/foo/lib
"REPL started; server listening on localhost:20092."
user=> (+ 1 2 3)
and thats all you really need. have fun :) (of course there is a LOT more to the clojure ecosystem though there is no need to really rush into it)
ps: add swank-clojure as a dev dependency and run lein swank and then slime-connect from within emacs
ps: I hit 'q' to exit the backtraces.
Here's an update for google: things have changed since the previous answers and the correct way to start swank/slime is now via the clojure-jack-in command in recent versions of clojure-mode, which uses the corresponding lein jack-in command in recent versions of swank-clojure. Using clojure-jack-in, all the Emacs dependencies other than clojure-mode are automatically installed for you. DO NOT install slime.el or slime-repl.el manually, via ELPA or via git.