leiningen project: repl-options/init - clojure

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.

Related

Unable to get `cider-jack-in` to work

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.

Failing to connect to compojure-app with LightTable

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.

lein repl fails: "No such var user/help"

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.

clojure.contrib.duck-streams FileNotFoundException, why?

user=> (use '[clojure.contrib.duck-streams])
java.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__in
it.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)
Clojure.contrib is in CLASSPATH still it is throwing Exception. Do I need some other Jar?
Use clojure.java.io instead, it's included with 1.2.
I highly recommend using leiningen to sort this out.
try the lein repl command to get a quick repl with a working classpath.
According to this message:
http://osdir.com/ml/clojure/2010-10/msg00834.html
clojure.contrib.duck-streams has been deprecated.

Which clojure jar contains clojure.contrib.io.Streams?

I am trying to compile some Clojure code to Java using the Clojure 1.2 compiler. I am including the Clojure and Clojure-contrib 1.2 jars in the classpath. When I do the compile it fails and I get the folowing error:
Exception in thread "main" java.lang.ClassNotFoundException: clojure.contrib.io.Streams (io.clj:121)
: Has anyone seen this before?
Update:
Here is the line I use to compile my clj files:
java -cp "..\lib\h2.jar;..\lib\vaadin-6.4.4.jar;..\lib\clojure.jar;..\lib\clojure-contrib.jar;..\lib\wlfullclient-10.3.0.0.jar;..\..\..\..\..\jre1.6windows32bit\lib\rt.jar;." -Dclojure.compile.path=cljclasses clojure.lang.Compile oe.main.oe-main
clojure.contrib.io.Streams is a protocol defined in clojure.contrib.io
To help you more you have to share more details about how and what you are trying to compile.
use (compile 'oe.main.oe-main) from a clojure REPL using the same class path, and this works