Fork me on GitHub
#tools-deps
<
2020-11-16
>
jplaza18:11:43

Hi! I’m having this issue https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows#long-classpath is there any other workaround besides the {:mvn/local-repo "/path/to/repo"} one? That is not working either

borkdude18:11:57

@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

terohe13:11:59

I tried the @$CpFile suggested and seemed to work. Added a sample diff here: https://github.com/clojure/brew-install/pull/4#issuecomment-728905508 Doesn't check the Java version though so would need something extra for Java 8 (if needed).

borkdude18:11:18

@jplaza

[email protected] /tmp $ clojure -Spath > classpath
[email protected] /tmp $ java -cp @classpath clojure.main
Clojure 1.10.1
user=>

borkdude18:11:15

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

borkdude18:11:30

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

borkdude19:11:49

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

borkdude19:11:25

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

borkdude19:11:14

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

borkdude19:11:09

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 :)

borkdude19:11:53

> 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?

borkdude19:11:52

I'll try java 8

borkdude19:11:21

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 @

borkdude19:11:52

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 @

borkdude19:11:29

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 @

borkdude19:11:37

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

Alex Miller (Clojure team)19:11:49

by calling java -version ?

borkdude19:11:08

$ 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?

borkdude19:11:22

$ 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

borkdude19:11:03

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

borkdude19:11:11

CLOJURE_CP_FILE=true

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

borkdude19:11:00

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

borkdude19:11:30

and only on Java 9+.

borkdude19:11:07

@jplaza what Java version are you using?

borkdude19:11:12

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

borkdude19:11:59

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

borkdude19:11:11

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

borkdude19:11:41

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

jplaza19:11:17

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

jplaza19:11:25

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

borkdude19:11:18

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

borkdude19:11:08

> 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?

jplaza19:11:34

Not sure but happens with both cmd and powershell

borkdude19:11:55

wsl2 is pretty good ;)

seancorfield19:11:55

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

borkdude19:11:08

Have you also tried portal btw?

seancorfield20:11:04

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

seancorfield19:11:20

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

jplaza20:11:12

Cool! Any tips on using Calva + WSL2?

seancorfield20:11:01

@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.

jplaza20:11:35

OK I will try that. I already cloned your deps.edn https://github.com/seancorfield/dot-clojure to play with the sock repl

borkdude21:11:51

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

borkdude21:11:28

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

💯 6
aw_yeah 3
jplaza22:11:34

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

👍 3
gmorpheme21:11:40

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 tools.build once that is out so I'm resisting the urge to make it better

gmorpheme09:11:29

understood, thanks

rickmoynihan09:11:03

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

gmorpheme09:11:42

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.

rickmoynihan11:11:55

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

rickmoynihan11:11:30

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

rickmoynihan11:11:57

See the updated README.md

pez22:11:36

@jplaza if you find out stuff about using WSL2 with Calva, please consider updating this page: https://calva.io/wsl/