tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2021-04-12T08:28:16.433500Z

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.

borkdude 2021-04-12T10:27:31.436900Z

Maybe you can write a script, if -Sdeps allows you to override the mvn repo dir

vlaaad 2021-04-12T10:31:39.437400Z

You can also use tools.deps as a library and add custom pre/post processing there

borkdude 2021-04-12T10:42:23.437600Z

true!

p-himik 2021-04-12T11:51:34.443100Z

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.

borkdude 2021-04-12T12:00:55.444800Z

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

p-himik 2021-04-12T12:05:25.445100Z

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.

borkdude 2021-04-12T12:06:36.445300Z

That could be a workaround indeed

alexmiller 2021-04-12T12:18:46.447100Z

We do have this captured in TDEPS-119 and I agree there needs to be some solution for it

đź‘Ť 1
borkdude 2021-04-12T15:45:57.449400Z

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)

đź‘Ť 1
erwinrooijakkers 2021-04-12T15:58:10.450500Z

Is there a way to upgrade dependencies automatically? A Leiningen’s lein ancient upgrade for tools.deps?

borkdude 2021-04-12T16:00:36.451500Z

@erwinrooijakkers That tool is called antq. There are multiple but that's the most actively maintained and complete one I believe

đź‘Ť 1
erwinrooijakkers 2021-04-12T16:01:05.452Z

great! started upgrading manually so just in time 🙂

erwinrooijakkers 2021-04-12T16:08:42.452600Z

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"]}}

tvaughan 2021-04-12T16:30:02.452700Z

This https://github.com/practicalli/clojure-deps-edn/ may also be a helpful resource

đź‘Ť 2
2021-04-12T16:46:14.457400Z

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?

seancorfield 2021-04-12T16:54:29.459600Z

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.

đź‘Ť 1
2021-04-12T16:56:51.459800Z

Thanks @seancorfield, worked like a charm!

alexmiller 2021-04-12T17:33:23.461500Z

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

lilactown 2021-04-12T17:40:13.462400Z

where's the docs for what options clj / clojure take? e.g. if I want to add a dependency via the CLI

lilactown 2021-04-12T17:40:43.462700Z

I'm skimming https://clojure.org/reference/deps_and_cli and don't see a list or a link to one

dharrigan 2021-04-12T17:42:11.463100Z

The file itself is a wrapper, so if you can examine the contents, you'll find the list of options

dharrigan 2021-04-12T17:42:34.463400Z

For example, on Arch linux, it's in /usr/bin/clojure

dharrigan 2021-04-12T17:42:43.463600Z

(which aliases to clj)

dharrigan 2021-04-12T17:43:42.464Z

It's also in the source repo <https://github.com/clojure/brew-install/blob/1.10.2/src/main/resources/clojure/install/clojure>

lread 2021-04-12T17:48:36.464100Z

Thanks, done: https://github.com/clojure/clojure-site/issues/521

lilactown 2021-04-12T17:55:06.464800Z

I don't know if this is the right channel to troubleshoot this

lilactown 2021-04-12T17:56:14.465300Z

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.

lilactown 2021-04-12T17:57:01.466100Z

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

dharrigan 2021-04-12T17:59:34.466300Z

Missing :deps

lilactown 2021-04-12T17:59:51.466600Z

ack I just figured that out 🤦

dharrigan 2021-04-12T17:59:59.466800Z

np 🙂 have fun! 🙂

1
alexmiller 2021-04-12T18:33:42.468800Z

https://clojure.org/reference/deps_and_cli also see -h and man clj)

alexmiller 2021-04-12T18:33:59.469200Z

Thx much

seancorfield 2021-04-12T18:58:07.469400Z

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

seancorfield 2021-04-12T19:01:37.469700Z

(! 1208)-&gt; 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)-&gt; clj -M:node-repl
ClojureScript 1.10.844
cljs.user=&gt; (* 1 2 3)
6
cljs.user=&gt;

psetmaj 2021-04-12T19:38:51.475Z

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.

psetmaj 2021-04-12T19:39:08.475100Z

Relevant part of my docker file

psetmaj 2021-04-12T19:40:25.475500Z

Relevant buildkit/docker build secrets documentation: https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information

dharrigan 2021-04-12T19:46:14.475800Z

This is something I have used in the past...

dharrigan 2021-04-12T19:46:23.476Z

(I use gitlab, but should be adaptable)

dharrigan 2021-04-12T19:46:55.476200Z

variables:
  DOCKER_HOST: "<tcp://docker:2375>"
  DEPS: '{:mvn/repos {"central" {:url "<http://nexus/repository/maven-public>"} "clojars" {:url "<http://nexus/repository/clojars>"}}}'

dharrigan 2021-04-12T19:47:08.476400Z

test:
  extends: .cache
  stage: test
  script:
    - clojure -Sdeps "${DEPS}" -A:test-runner
  cache:
    policy: push

dharrigan 2021-04-12T19:47:20.476600Z

nexus in the example above, is my own private repo.

psetmaj 2021-04-12T19:51:25.476800Z

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)

dharrigan 2021-04-12T19:54:55.477Z

I have anonymous access to pull from the repos

dharrigan 2021-04-12T19:55:03.477200Z

no need for authentication to pull 🙂

psetmaj 2021-04-12T19:55:38.477400Z

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

dharrigan 2021-04-12T19:57:27.477600Z

Not sure then, our company has anon access to pull artifacts

dharrigan 2021-04-12T19:57:49.477800Z

soz ;(

dharrigan 2021-04-12T19:58:16.478Z

Maybe someone else can help out 🙂

psetmaj 2021-04-12T19:59:08.478200Z

Thanks for trying 🙂

lilactown 2021-04-12T20:09:33.478400Z

that's great, thanks!

lilactown 2021-04-12T20:09:48.478600Z

ty! -h i think is what i wanted

nnichols 2021-04-12T20:13:46.478900Z

@psetmaj Are you using S3 as your internal repo?

psetmaj 2021-04-12T20:14:07.479100Z

No, using nexus

psetmaj 2021-04-12T20:57:43.479700Z

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