tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-11-16T15:33:50.399500Z

yup I’ve never questioned that… I’m just trying to improve this area for myself and maybe others in the interim

jplaza 2020-11-16T18:43:43.401100Z

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

borkdude 2020-11-16T18:52:57.402200Z

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

alexmiller 2020-11-16T18:53:30.402700Z

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

alexmiller 2020-11-16T18:54:12.402900Z

https://clojure.atlassian.net/browse/TDEPS-120

terohe 2020-11-17T13:06:59.451100Z

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

borkdude 2020-11-16T18:56:18.403300Z

@jplaza

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

borkdude 2020-11-16T18:57:15.403700Z

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

borkdude 2020-11-16T18:57:30.404100Z

Tools.deps / clojure CLI might leverage the same workaround

alexmiller 2020-11-16T18:57:46.404400Z

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

borkdude 2020-11-16T18:58:25.404600Z

yeah

alexmiller 2020-11-16T18:59:23.404800Z

this would actually be trivial

alexmiller 2020-11-16T18:59:39.405200Z

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

alexmiller 2020-11-16T19:01:56.406600Z

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

alexmiller 2020-11-16T19:02:22.406800Z

$CP here is the name of a classpath file

alexmiller 2020-11-16T19:03:35.407800Z

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

alexmiller 2020-11-16T19:04:03.408300Z

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

borkdude 2020-11-16T19:04:49.409200Z

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

borkdude 2020-11-16T19:05:25.409700Z

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

alexmiller 2020-11-16T19:06:32.410600Z

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

borkdude 2020-11-16T19:06:40.410800Z

yes

borkdude 2020-11-16T19:10:14.411300Z

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

borkdude 2020-11-16T19:14:09.411700Z

The java docstring doesn't mention this explicitly

alexmiller 2020-11-16T19:16:29.412Z

been around for a long time

alexmiller 2020-11-16T19:16:51.412400Z

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

borkdude 2020-11-16T19:17:53.412800Z

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

alexmiller 2020-11-16T19:18:40.413Z

looks like maybe java 9?

borkdude 2020-11-16T19:18:52.413300Z

I'll try java 8

borkdude 2020-11-16T19:19:21.413600Z

nope, didn't work

alexmiller 2020-11-16T19:19:28.413800Z

def doc'ed here https://docs.oracle.com/javase/9/tools/java.htm

alexmiller 2020-11-16T19:20:21.414500Z

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

alexmiller 2020-11-16T19:21:23.415500Z

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

borkdude 2020-11-16T19:21:52.416200Z

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

alexmiller 2020-11-16T19:21:52.416300Z

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

borkdude 2020-11-16T19:23:29.417400Z

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

alexmiller 2020-11-16T19:24:32.417600Z

I don't think you need that

alexmiller 2020-11-16T19:25:02.418200Z

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

borkdude 2020-11-16T19:25:37.418600Z

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

alexmiller 2020-11-16T19:25:49.418800Z

by calling java -version ?

borkdude 2020-11-16T19:26:08.419200Z

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

alexmiller 2020-11-16T19:27:06.419900Z

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

borkdude 2020-11-16T19:27:22.420100Z

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

alexmiller 2020-11-16T19:27:44.420300Z

not too distinguishable then

borkdude 2020-11-16T19:28:03.420900Z

Maybe this can be controlled via an environment variable

alexmiller 2020-11-16T19:28:05.421200Z

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

borkdude 2020-11-16T19:28:11.421500Z

CLOJURE_CP_FILE=true

alexmiller 2020-11-16T19:28:21.421800Z

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

alexmiller 2020-11-16T19:28:38.422Z

might be the cleanest though

borkdude 2020-11-16T19:29:00.422300Z

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

alexmiller 2020-11-16T19:29:11.422500Z

that's fine

borkdude 2020-11-16T19:29:30.422700Z

and only on Java 9+.

borkdude 2020-11-16T19:30:07.423Z

@jplaza what Java version are you using?

borkdude 2020-11-16T19:32:12.423700Z

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

alexmiller 2020-11-16T19:34:31.423900Z

bleh

borkdude 2020-11-16T19:34:59.424400Z

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

borkdude 2020-11-16T19:36:11.424700Z

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

alexmiller 2020-11-16T19:36:24.424900Z

who knows if that day will ever come

borkdude 2020-11-16T19:37:41.425600Z

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

jplaza 2020-11-16T19:41:17.427100Z

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

jplaza 2020-11-16T19:42:25.428300Z

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

borkdude 2020-11-16T19:42:31.428400Z

as a quick workaround: https://clojurians.slack.com/archives/C6QH853H8/p1605552978403300

borkdude 2020-11-16T19:43:18.428900Z

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

jplaza 2020-11-16T19:46:50.429900Z

😆

borkdude 2020-11-16T19:47:08.430400Z

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

jplaza 2020-11-16T19:48:34.430700Z

Not sure but happens with both cmd and powershell

borkdude 2020-11-16T19:48:55.430900Z

wsl2 is pretty good ;)

seancorfield 2020-11-16T19:51:55.431600Z

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

seancorfield 2020-11-16T19:52:20.432100Z

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

borkdude 2020-11-16T19:53:08.432200Z

Have you also tried portal btw?

seancorfield 2020-11-16T20:01:04.432400Z

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

jplaza 2020-11-16T20:51:12.433Z

Cool! Any tips on using Calva + WSL2?

seancorfield 2020-11-16T20:53:01.434300Z

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

jplaza 2020-11-16T20:59:35.436100Z

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

borkdude 2020-11-16T21:00:51.436700Z

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

borkdude 2020-11-16T21:01:28.437600Z

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

2💯1
gmorpheme 2020-11-16T21:32:40.444200Z

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?

alexmiller 2020-11-16T21:57:28.444400Z

it does not pass those through right now

alexmiller 2020-11-16T21:57:53.444900Z

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

gmorpheme 2020-11-17T09:11:29.449Z

understood, thanks

2020-11-17T09:27:42.449200Z

In the mean time you might try this: https://github.com/rickmoynihan/pom-update

2020-11-17T09:29:03.449500Z

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

gmorpheme 2020-11-17T09:41:42.449700Z

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.

2020-11-17T11:02:55.449900Z

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.

2020-11-17T11:03:02.450100Z

Fixed.

2020-11-17T11:03:30.450300Z

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

2020-11-17T11:03:57.450600Z

See the updated README.md

pez 2020-11-16T22:12:36.446Z

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

jplaza 2020-11-16T22:34:34.448100Z

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

1👍
jplaza 2020-11-16T22:35:09.448500Z

Will do