Fork me on GitHub
#tools-deps
<
2022-02-22
>
Carsten Behring17:02:59

I am experimenting running Clojure REPL in a podmain container which has a kind of "restricted" $HOME directory. (read-only and a lot of environment variables are not set). I saw that starting clojure clojure CLI tries to download clojure jars from maven, and tries to write them into /.m2/ I could not find anywhere what controls the place of writing of the jars. It is not HOME, neither M2_REPO environment vars because changing them does not make a difference. Is there a way to configure this location ? For reference the exception is:

at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.clojure:clojure:pom:1.10.3 from/to central (): /.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.pom.part.lock (No such file or directory)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:425)
	at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:229)
	at org.eclipse.aether.internal.impl.

Carsten Behring17:02:22

Thanks, saw it now.

Carsten Behring18:02:10

Hmm. It uses the "tilde" which I cannot change. And inside the container there is no ".clojure/deps.edn" file (yet) which I could change.

Carsten Behring18:02:51

So in some form the clojure CLI cannot run in an environment (container) where the "current user" has no home directory assigned in the /etc/passwd file (and this is the source for the ~ expansion) Even Though the place for the .clojure directory can be changed, the place for m2 cannot, at least not "in one go".

Carsten Behring18:02:43

To have this automated, would require a 4 step process: 1. export HOME=/tmp 2. clojure -e ":ok" -> will create /tmp/.clojure/deps.edn 3. some command line magic to set :mvn/local-repo inside /tmp/.clojure/deps.edn

Alex Miller (Clojure team)18:02:24

you can use -Sdeps '{:mvn/local-repo "wherever"}'

Alex Miller (Clojure team)18:02:44

it's unclear to me if that addresses everything you need

Alex Miller (Clojure team)18:02:42

you don't need a .clojure/deps.edn (using -Srepro will skip it, but I'm not sure that's even needed here)

Carsten Behring18:02:03

yes, it does. That was the trick. Thanks.

orestis19:02:03

If I see . com.google.guava/guava 31.0.1-jre :newer-version in the output of clojure -Stree, should I expect that I'm using this version of guava? And if so, why does putting an explicit dep of that same version at the top level of my deps.edn fix my issue?

orestis19:02:05

Using Clojure CLI version 1.10.3.1040, trying now with also 1.10.3.1075

seancorfield19:02:43

t.d.a prefers top-level versions over transitive deps by design so you can easily control this sort of thing.

seancorfield19:02:12

The . means "using this". If it had X it would mean "not using this".

orestis19:02:38

Ah never mind, I was running my -Stree with slightly different aliases.

orestis19:02:27

Never mind, I was running -Stree with an extra alias that was bringing in this version, but under normal circumstances it wasn't. Sorry for the noise.