Fork me on GitHub

Hi! I’m having this issue is there any other workaround besides the {:mvn/local-repo "/path/to/repo"} one? That is not working either


@jplaza Hmmm. You could spit out the classpath to a file and then start Clojure using java -cp @classpath-file clojure.main but this is a bit spartan maybe.

Alex Miller (Clojure team)18:11:30

there is a ticket with some work on it but I don't know that they are workarounds currently


I tried the @$CpFile suggested and seemed to work. Added a sample diff here: Doesn't check the Java version though so would need something extra for Java 8 (if needed).



borkdude@MBP2019 /tmp $ clojure -Spath > classpath
borkdude@MBP2019 /tmp $ java -cp @classpath clojure.main
Clojure 1.10.1


What this does: java reads the classpath from a file here.


Tools.deps / clojure CLI might leverage the same workaround

Alex Miller (Clojure team)18:11:46

seems like it could easily do so since it always has a classpath file already :)

Alex Miller (Clojure team)18:11:23

this would actually be trivial

Alex Miller (Clojure team)18:11:39

if you wanted to hack your ClojureTools.psm1 and try it

Alex Miller (Clojure team)19:11:56

basically where you have -classpath $CP if you changed that to "@$CP" (probably not the right syntax but that's the idea) in like line 396

Alex Miller (Clojure team)19:11:22

$CP here is the name of a classpath file

Alex Miller (Clojure team)19:11:35

the exec case is maybe the hardest as it adds the special exec jar: -classpath "$CP;$InstallDir/exec.jar" so might need to emit a well-known variant for that case or something

Alex Miller (Clojure team)19:11:03

if someone wanted to work on a patch, would be happy to integrate that


you would have to append $InstallDir/exec.jar to the classpath file and then read that. Probably better to append it to some other file classpath-exec and then use that one


afaik you can only use one @ and not in combination with non-file classpath

Alex Miller (Clojure team)19:11:32

yes that would be my expectation. I'm suggesting that right now we write 12341234.cp and we could also write 12341234-exec.cp (which included the exec jar) and use that instead for the -X case


You might want to check compatibility of this over several java versions


The java docstring doesn't mention this explicitly

Alex Miller (Clojure team)19:11:29

been around for a long time

Alex Miller (Clojure team)19:11:51

if it works on Java 8, then it's ok by me :)


> been around for a long time where do you find docs about this?

Alex Miller (Clojure team)19:11:40

looks like maybe java 9?


I'll try java 8


nope, didn't work

Alex Miller (Clojure team)19:11:21

I think maybe it was added in java 9 based on my googling. I thought it was older than that

Alex Miller (Clojure team)19:11:23

well, could make it version dependent - if java version is 9+, use @


Right, it seems the @argument file thing applies to every option

Alex Miller (Clojure team)19:11:52

or maybe invert, if Java version is 8, don't use @


Yeah, that makes sense. That will assume you will not re-use your cache for different java versions, so maybe include the java version in the cache hash if you haven't already

Alex Miller (Clojure team)19:11:32

I don't think you need that

Alex Miller (Clojure team)19:11:02

the files are the same either way, it's just whether or not you can use it via @


right. how will the CLI know which java version is used?

Alex Miller (Clojure team)19:11:49

by calling java -version ?


$ time java -version
java -version   0.07s  user 0.06s system 94% cpu 0.136 total

Alex Miller (Clojure team)19:11:06

what's the error if you use the @file on java 8?


$ java -cp @classpath clojure.main
Error: Could not find or load main class clojure.main

Alex Miller (Clojure team)19:11:44

not too distinguishable then


Maybe this can be controlled via an environment variable

Alex Miller (Clojure team)19:11:05

I was wondering if you could just assume it would work, detect the failure and retry



Alex Miller (Clojure team)19:11:21

yeah, it could be an env var too. I was trying to avoid that :)

Alex Miller (Clojure team)19:11:38

might be the cleanest though


for those experiencing this problem, they would set it, others won't


and only on Java 9+.


@jplaza what Java version are you using?


@alexmiller alternative dirty workaround: use add-lib to load the libs later on ;)


yeah, I said dirty, but it's always good to list alternatives, even when they're bad ;)


another alternative: won't fix until Java 8 isn't supported anymore :)

Alex Miller (Clojure team)19:11:24

who knows if that day will ever come


another alternative: reverse engineer the java command line tool and build a nicer front-end which supports this for older java versions ;)


Thanks for the fast reply @alexmiller @borkdude! I’m helping a teammate with that issue. She has java 9.


I told her the problem is that she’s using Windows haha! She’s installing Windows Subsytem for Linux


this isn't Windows's fault, more or less java's. No sorry, it's Window's fault ;)


> Windows command-line length limit Does this apply to cmd.exe, powershell.exe or is it a conhost limit? Do you experience the same problem with the new Windows Terminal?


Not sure but happens with both cmd and powershell


wsl2 is pretty good ;)


Yeah, I gave up on the whole Powershell thing and just do everything on WSL2 now. Esp. with VS Code's Remote-WSL2 extension.


Have you also tried portal btw?


Yes, but I prefer to dock a GUI next to my editor rather than switch back and forth between an editor and a browser.


(I run VcXsrv aka Xlaunch so I can start X11-based GUIs from WSL2, such as REBL or Reveal)


Cool! Any tips on using Calva + WSL2?


@jplaza I use Clover with VS Code. I like working with a plain Socket REPL in processes -- I avoid nREPL and all that stuff. Clover is "Chlorine for VS Code" and I was previously using Chlorine on Atom.


OK I will try that. I already cloned your deps.edn to play with the sock repl


@jplaza Many people use Calva. Check out #calva. There's a lot going on there.


@jplaza Also check out out the clj-kondo plugin for VScode </shameless-plug>

💯 6
aw_yeah 3

We use clj-kondo in our team! Awesome tool! I actually mentioned our startup in the issue so you can list us there 😉

👍 3

I assumed clojure -X:deps mvn-pom :lib 'foo/bar' :version '"0.0.1-SNAPSHOT"' would generate generate me a POM with the specified details but I’m not having any luck - I just get defaults. (Maybe mvn-pom doesn’t pass the args on through to sync-pom?). Was this not an intended usage? Or am I missing something? Or just an oversight?

Alex Miller (Clojure team)21:11:28

it does not pass those through right now

Alex Miller (Clojure team)21:11:53

mvn-pom may go away in favor of once that is out so I'm resisting the urge to make it better


understood, thanks


hot off the press so YMMV, I’ve not even properly announced it yet.


Thanks - works for me if I generate the POM with tools.deps then update the version with pom-update. I needed to add :pom/write-strategy :overwrite :pom/input-file '"pom.xml"' explicitly though.


oh yes thanks that’s intentional, I just forgot to add that to the when I wrote it up last night. I’ll do that now. Thanks for letting me know.


My recommendation is that you include those in your deps.edn rather than via command line, as they won’t vary across calls.


See the updated


@jplaza if you find out stuff about using WSL2 with Calva, please consider updating this page: