I’ve been updating some of my projects to use the newly released Java 8. That includes many Clojure projects. These are just “flow of consciousness” debugging notes.
Under Linux, things work as expected. Things are not so straightforward under Windows.
At a command prompt,
lein version produces the following output, as expected:
When I run
lein version as an Emacs shell command, the output is:
Running in a Clojure REPL under Emacs produces the similar:
What’s going on?
The Leiningen sample project file at https://github.com/technomancy/leiningen/blob/master/sample.project.clj says that Leiningen’s own JVM is set with the
LEIN_JAVA_CMD environment variable. In my case, no such variable is set. As I interpret the
lein.bat file, that means that the java used defaults to simple “java”. I would think that means the same Java used by the Windows command prompt. Apparently not.
Creating the Windows environment variable
LEIN_JAVA_CMD and setting it to
C:\Program Files\Java\jdk1.8.0\bin\java gets the desired effect when we ask Leiningen for its version number in an Emacs shell command.
However, things are even weirder at the REPL.
Where did that come from?
I have JDK versions 1.7.0_17, _21, _25, _40, _45, _51, and 1.8.0 installed on my system. How are these choices being made?
Tried updating to CIDER. Same results.
Running LightTable (version 0.6.5) and starting an InstaRepl also produces the same result
Running the Clojure REPL directly from the command line give the expected result:
Turns out there is a line in the user profile,
C:\Users\david\.lein\users.clj, that seems to be messing things up.
Not sure why that was in there. Removing that line also lets me remove the environment variable and the results from the emacs shell gives the correct result. However, the REPLs report version 1.7.0_40.
Giving up, I remove versions _17, _21, _25, _40, and _45 (leaving _51 in place). Now everything works as desired, all REPLs and shell commands reporting the correct version. Sheesh.