Cannot use Clojure 1.7 with Leiningen - clojure

Using Leiningen, I'm unable to use Clojure 1.7 in project, but I am able to use later versions.
For instance, if I clone down the Om Next Tutorial and try to run it, I get a java.lang.NoClassDefFoundError: clojure/lang/Tuple. Full stack trace here. A similar error occurs any time I try to use Clojure 1.7 in a project with Leiningen.
However, the error goes away if I upgrade to Clojure 1.8 or 1.9 in project.clj. The trouble is that I'm not always in a position to upgrade the version on a project.
Versions installed:
Clojure: 1.8.0
Java: OpenJDK 1.8.0_171
Leiningen: 2.8.1
Ubuntu: 16.04 LTS
The problem happens with or without my lien profiles.clj.
I'm not a Java expert, but this looks like a classpath issue to me. I am using update-java-alternatives to set the path to Java 1.8.
Edit: I created a minimal repo that reproduced the problem, using the very first part of the Om Next tutorial, here.

Related

I have an error in Clojure and leiningen command

I am working on a project in Clojure. I tried to migrate my latest DB commit to my local using the command
PROFILE=dev lein ragtime migrate
Getting this error:
clojure.lang.Compiler$CompilerException: Syntax error macroexpanding
clojure.core/fn at (clojure/core/unify.clj:83:18).
:clojure.error{:phase :macro-syntax-check, :line 83, :column 18,
:source "clojure/core/unify.clj", :symbol clojure.core/fn}
I also encountered this issue with Leiningen 2.9.1. In my case it turned out to occur due to the lein-ring plugin which depends on an outdated unify version. The issue is already fixed in the newest lein-ring version though: https://github.com/weavejester/lein-ring/issues/203. So upgrading lein-ring to 0.12.5 fixed it for me.
I'm not 100% sure what this issue is, but it seems to be related to leiningen 2.9.x.
At first, I ran leiningen v 2.8.x (don't remember which version exactly). Then everything worked fine.
Then I updated leiningen to 2.9.1, and I got this error the next time I tried to build with leiningen.
We then updated ring from version 1.4.0 to 1.7.1, and the error disappeared.
Alternatively, if you have to use an old version of a library, the only fix seems to be to downgrade to leiningen 2.8:
lein upgrade 2.8.3
Downgraded to 2.7.1 and it worked for me
Maybe your project.clj is malformed. I wonder where the ragtime command comes from? It seems that the previous developer implemented their own plugin for ragtime integration because it differs from the way suggested in the official wiki. It would be nice if you share some bits of your project.clj as well as the code that provides the connection b/w ragtime and lein.

Can I make leiningen use a specific javac version?

Our build server has multiple versions of Java, to support our legacy projects that haven't yet updated to Java 1.8.
javac -version returns 1.7, which is what leiningen picks up (from /usr/bin/javac).
Is there a way to tell leiningen to use a different version of javac?
eg. we have 1.8 installed at /home/ubuntu/jdk1.8.0_11/bin/javac
Ghetto solution I came up with:
PATH=/home/ubuntu/jdk1.8.0_11/bin/:$PATH lein dist
I'm hoping there's an alternative approach.

How to configure leiningen to use newest Clojure version for repl started outside of project?

When I start clojure repl for specific project, for leiningen is enough to specify correct clojure version in the concrete project.clj file as described here. But when I start repl outside the project then the older version is started. In my case the older version is 1.5.1 and I want to upgrade to 1.6.0. Here has proposed not working solution, but in the comments bellow is said that in lieingen version 2.1 the problem is resolved. I'm with version 2.3.4 of leiningen but the proposed solution doesn't work for me.
according to technomancy on IRC: "repls outside projects are hard coded
to lein's version of clojure"
Source: https://github.com/technomancy/leiningen/issues/1035#issuecomment-35927505

How do I install Clojure 1.3 with contribs on RHEL 6.1 / JDK7?

I've been struggling a bit trying to get this to work. Getting clojure 1.3 was a breeze, but now I've been trying to get contrib libraries to install and I get errors. Is there a guide on how to do this correctly?
The old clojure.contrib monolithic library is incompatible with clojure 1.3. See http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
As for how to install libraries correctly, either write your own pom.xml and use maven or use leiningen (much easier!) - https://github.com/technomancy/leiningen

IllegalStateException Compiling Clojure-Contrib

I am trying to compile my own version of clojure-contrib with Maven I get the following exception:
Exception in thread "main" java.lang.IllegalStateException: Can't dynamically bind non-dynamic var: clojure.contrib.pprint/*format-str*, compiling:(dispatch.clj:90)
I am also using the following command to compile it:
mvn package -Dclojure.jar=/usr/local/share/jars/clojure.jar
clojure.jar is link to the actual jar (that is on the same directory) because I am using a version that I compiled from the Git repository.
Any Ideas?
Thanks in advance for your comments! =)
clojure-contrib, the single monolithic build, is deprecated after Clojure 1.2.0 and is not actively maintained. It doesn't build on the latest Clojure 1.3.0-alpha* releases.
New contrib libraries, one per Github repository, are being created under http://github.com/clojure
See http://dev.clojure.org/display/design/Clojure+Contrib and its sub-pages for more information.