Is it possible to eval some clojure code inside deps.edn? The idea is, if some ENV variable is set to true, modify the mvn repo directory.
Maybe you can write a script, if -Sdeps
allows you to override the mvn repo dir
You can also use tools.deps as a library and add custom pre/post processing there
true!
The page at https://clojure.org/reference/deps_and_cli#_classpath_caching makes it clear that it's impossible to override the path to .cpcache
when deps.edn
is present.
I wonder whether it would be useful to have such an ability.
Consider a situation where you need to give someone a read-only access to some src-based project, just so that they can run the clj
command with some useful aliases.
It will require the .cpcache
dir to be writable for that user. And, I think, that opens a possibility for injections, when that user changes the cache in some malevolent way and some other user with higher privileges ends up using that cached classpath.
If it were possible to override path to .cpcache
when deps.edn
is present, a user with low privileges can be instructed to just use some personal directory.
In the scenario above, maybe completely disabling such a cache for such users would be useful.
@p-himik The way the clojure CLI currently works is that the cache files contain a return value from tools.deps. Those are always read from the file system or when not available, created by invoking tools.deps. So you can't run without the cache, currently. But I agree that making the cache dir configurable/overridable would be useful for the above scenario.
Thanks!
In that case, disabling the cache can implicitly create an auto-generated temp directory, to prevent two users from using the same temp cache directory accidentally, like /tmp/my-proj/cpcache
.
But perhaps a better term than "disabling the cache" could be used in the documentation, to avoid any misunderstandings.
That could be a workaround indeed
We do have this captured in TDEPS-119 and I agree there needs to be some solution for it
Working on a task runner. One goal is to create shortcuts for various clojure invocations, but another thing falling out of the feature to run deps in parallel is to create a dev env that runs multiple processes in the background. Just sharing this for early feedback. This is my version from work. (we have more tasks like uberjar, but I've only included those that I invoke from the command line regularly today)
Is there a way to upgrade dependencies automatically? A Leiningen’s lein ancient upgrade
for tools.deps?
@erwinrooijakkers That tool is called antq. There are multiple but that's the most actively maintained and complete one I believe
great! started upgrading manually so just in time 🙂
thanks! works like a charm
:aliases {:upgrade-deps {:extra-deps {com.github.liquidz/antq {:mvn/version "0.12.4"}}
:main-opts ["-m" "antq.core" "--upgrade" "--force"]}}
This https://github.com/practicalli/clojure-deps-edn/ may also be a helpful resource
Hi all, I'm trying to use clojure -X:my-alias:deps tree
to inspect the dependencies of my application but none of the dependencies that are being brought in by :my-alias
via :extra-deps
are showing up anywhere in the output tree. I can confirm that :my-alias
bings in the relevant dependencies in the running application. Is this the correct usage? Is -X:deps tree
meant to work with other aliases?
Hiya! Just noticed that https://github.com/clojure/tools.deps.alpha/blob/9bf5778dc26dd5018dbf04fc8e7dbb32ddc4036c/src/main/clojure/clojure/tools/deps/alpha.clj#L611 but the https://github.com/clojure/tools.deps.alpha/blob/master/API.md.
You can use clojure -A:my-alias -Stree
for the time being. There’s currently no way to tell -X:deps tree
to use aliases when it is computing the project basis.
Thanks @seancorfield, worked like a charm!
Thanks, I’m not at a computer right now but if you could file an issue at https://github.com/clojure/clojure-site/issues that would be helpful for me to remember
where's the docs for what options clj
/ clojure
take? e.g. if I want to add a dependency via the CLI
I'm skimming https://clojure.org/reference/deps_and_cli and don't see a list or a link to one
The file itself is a wrapper, so if you can examine the contents, you'll find the list of options
For example, on Arch linux, it's in /usr/bin/clojure
(which aliases to clj
)
It's also in the source repo <https://github.com/clojure/brew-install/blob/1.10.2/src/main/resources/clojure/install/clojure>
Thanks, done: https://github.com/clojure/clojure-site/issues/521
I don't know if this is the right channel to troubleshoot this
I'm trying to run a node REPL outside of a project. here's my current attempt:
$ clj -Sdeps '{org.clojure/clojurescript {:mvn/version "1.10.844"}}' -m cljs.main --repl-env node
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate cljs/main__init.class, cljs/main.clj or cljs/main.cljc on classpath.
I've also been trying to write an alias to put in my ~/.clojure/deps.edn
and I cannot figure out how to specify the -m cljs.main
part
Missing :deps
ack I just figured that out 🤦
np 🙂 have fun! 🙂
https://clojure.org/reference/deps_and_cli also see -h and man clj)
Thx much
Under :aliases
:
:node-repl
{:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}
:main-opts ["-m" "cljs.main" "--repl-env" "node"]}
and then clj -M:node-repl
(! 1208)-> cat deps.edn
{:aliases
{:node-repl
{:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.844"}}
:main-opts ["-m" "cljs.main" "--repl-env" "node"]}
}}
(! 1209)-> clj -M:node-repl
ClojureScript 1.10.844
cljs.user=> (* 1 2 3)
6
cljs.user=>
Is there a way to override the searched locations for a maven settings.xml?
I’m trying to get a reasonable tools-deps jenkins pipeline working (using docker agents to minimize the need for installing things on jenkins), but I’m having trouble getting tools-deps to access a private maven repo from within docker.
The projects that use maven get their credentials through a fancifully-provided settings file and include a flag on each maven call to specify it as the one to use (e.g. mvn -s ./provided/settings.xml clean install
). Docker doesn’t seem to like me copying things into ~/.m2
, so I’m wondering if there’s something like the -s
mvn
flag for specifying the maven settings to use in clj
.
Relevant part of my docker file
Relevant buildkit/docker build secrets documentation: https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information
This is something I have used in the past...
(I use gitlab, but should be adaptable)
variables:
DOCKER_HOST: "<tcp://docker:2375>"
DEPS: '{:mvn/repos {"central" {:url "<http://nexus/repository/maven-public>"} "clojars" {:url "<http://nexus/repository/clojars>"}}}'
test:
extends: .cache
stage: test
script:
- clojure -Sdeps "${DEPS}" -A:test-runner
cache:
policy: push
nexus
in the example above, is my own private repo.
I have private repos working locally on my machine outside docker, but getting the credentials into docker is proving funky (I don’t see where that’s happening above)
I have anonymous access to pull from the repos
no need for authentication to pull 🙂
That makes sense in most cases, this is for grabbing a company-internal Java library that’d be kind of hard to recreate/vendor in properly
Not sure then, our company has anon access to pull artifacts
soz ;(
Maybe someone else can help out 🙂
Thanks for trying 🙂
that's great, thanks!
ty! -h
i think is what i wanted
@psetmaj Are you using S3 as your internal repo?
No, using nexus
Newest relevant section of Dockerfile, tried some more experimentation and confirmed that RUN cat ~/.m2/settings.xml
inside docker reveals the correct file that works when using tools-deps outside docker in the “same” position