tools-deps 2024-04-04

In a project with a deps.edn file is it possible for me to start a clojure process that has only the dependencies listed in the :extra-deps one of the aliases ? My alias is :build. My goal would be to run clj -T:build deps and execute some off-the-beaten path code in order to procure maven dependencies that are specified in top level :deps map.

https://clojure.org/guides/tools_build say > Tools executed with -T:an-alias remove all project deps and paths, add "." as a path, and include any other deps or paths as defined in :an-alias. which sounds like what I want. But if I have a dependency in my :deps key that can't be downloaded by the normal means, then an exception will be thrown before my function can be run. In my case:

Execution error (NoTransporterException) ...
Cannot access  ...
I have code that can pull this missing dependency in my build.clj, but I can't reach that code because the default dependency resolution errors out too early. https://clojure.atlassian.net/browse/TDEPS-257?

Alex Miller (Clojure team) 2024-04-04T16:36:37.291639Z

Can you share the full actual error when this happens?

false alarm, sorry. I didn't realize that I had a top-level call to (b/create-basis {:project "deps.edn"}) in my build.clj which is where the error was coming from. A good reminder to myself and others to look at the helpful /tmp/clojure-<...>.edn files on error 😏 Thanks, Alex

Alex Miller (Clojure team) 2024-04-04T16:50:11.440419Z

I actually changed the guide examples to delay that basis creation for similar reasons

This made me double-check the project templates in deps-new -- but they all create the basis as-needed inside functions rather than at the top-level, so they already avoid this problem. I will have to check https://clojure-doc.org (the tools.build cookbook) but I think it already advocates the approach I take in deps-new...

Yup, all five instances of create-basis are inside functions and evaluated as needed with aliases.