Fork me on GitHub
#leiningen
<
2023-10-25
>
John00:10:37

I'm having a hard time setting up dep cache in CI. Unless I can embed some logic in the :local-repo key to check for an environment variable, I want to control it from the outside. export MAVEN_OPTS=-Dmaven.local.repo does not seem to be having an effect -- the resulting cache folder is empty at the end

John00:10:20

Having a CI profile setting :local-repo is one idea

John00:10:45

I guess update-in as well but not sure how to combine it with a getenv

mikerod01:10:17

You can eval in from env vars in the project.clj.

mikerod01:10:00

This is similar to something I had setup for a similar case before.

mikerod01:10:53

You should also be able to update-in though if you wanted to go that route. Something like:

lein update-in : assoc :local-repo "$CUSTOM_LOCAL_REPO" -- <task>
I’d think.

Alex Miller (Clojure team)01:10:21

There is support for this in the :mvn/local-repo key in the deps edn

😮 2
Alex Miller (Clojure team)01:10:57

And you can pass these dynamically on the command line with -Sdeps

Alex Miller (Clojure team)01:10:49

clj -Sdeps ‘{:mvn/local-repo “whatever”}’

Alex Miller (Clojure team)01:10:20

Or the do the right quotey thing with an env var there

Alex Miller (Clojure team)01:10:07

This is for the Clojure CLI but maybe I misunderstood and you are using lein ?

Alex Miller (Clojure team)01:10:37

Oh, we are in leinigen, my bad I probably just confused it all :)

🚀 1
hifumi12303:10:01

@U0LK1552A you can also use lein change assoc :local-repo "path/to/somewhere" if you want to persist the changes to the project.clj file in case multiple commands are invoked separately during CI

👍 1
hifumi12303:10:17

@U064X3EF3 minor caveat: tools.build will not see that information unless you patch the code that creates a basis. I learned this the hard way when invoking clojure exactly as you described for a project that uses tools.deps

hifumi12303:10:03

the solution in the end was patching the build.clj file since tools.build does not pick up certain keys from Sdeps IME

Alex Miller (Clojure team)10:10:32

@U0479UCF48H that doesn't seem accurate, but feel free to follow up in #C6QH853H8 or #C02B5GHQWP4 if you have more on that

John10:10:37

ahh ~( is what it is, and java.lang potentially being required is the other thing I hadn't realized. tyvm guys