tools-deps

vemv 2023-08-26T09:12:48.583679Z

I can ask it but perhaps it's easy enough What I am doing wrong here?

user> (tools.deps/resolve-deps {:deps '{com.google.cloud.opentelemetry/exporter-trace {:mvn/version "0.25.2"}}}
                                                         {})
Execution error (ArtifactNotFoundException) at org.eclipse.aether.internal.impl.DefaultArtifactResolver/resolve (DefaultArtifactResolver.java:496).
Could not find artifact org.apache:apache:pom:21
When depending on com.google.cloud.opentelemetry/exporter-trace via deps.edn, it works fine and it gets added to the classpath. But with programmatic usage, it chokes on https://mvnrepository.com/artifact/org.apache/apache/21 , which to be fair looks like an odd dependency: [org.apache/apache "21" :extension "pom"] I have tried different variations of programmatic usage, no luck

Alex Miller (Clojure team) 2023-08-26T12:32:40.659889Z

The last argument of resolve-deps is the procurer config - you’re passing an empty map which means you are defining no maven repos, so nothing will be found

Alex Miller (Clojure team) 2023-08-26T12:35:03.585689Z

You can instead pass the var defining the standard repos https://github.com/clojure/tools.deps/blob/52a1e172457fe934bbcfb8e5a216ecd1f37590fa/src/main/clojure/clojure/tools/deps/util/maven.clj#L61

Alex Miller (Clojure team) 2023-08-26T12:36:57.027539Z

Or rather, those need to be in the first arg (see https://github.com/clojure/tools.deps/blob/52a1e172457fe934bbcfb8e5a216ecd1f37590fa/src/main/clojure/clojure/tools/deps.clj#L955 example)

vemv 2023-08-26T13:54:32.230999Z

Thanks, Alex! specifying :mvn/repos worked. Perhaps the behavior when they're nil/empty could be improved? In this thread I showed one way in which errors won't point in that direction. In this other question I posted another https://ask.clojure.org/index.php/13201/clojure-tools-deps-calc-basis-unable-resolve-version-range It would probably make sense to fail-fast when performing maven ops with no repos backing them? Or at least, include that info prominently in the ex-msg / ex-data.

Alex Miller (Clojure team) 2023-08-26T16:09:24.852319Z

It's important to separate the CLI (which provides a lot of assumptions and defaults) from the lib. The lib is a more general tool and you have to provide more context. You don't need to pass any maven repos if you're doing git-only stuff for example, so it's not an error to not have repos. If you get unable to resolve, that's what it means - the lib you asked for can't be found in the repos given. There's no way to know if that's because you didn't provide the right repos or if the lib doesn't exist.

Alex Miller (Clojure team) 2023-08-26T16:09:58.511459Z

even if you don't have repos you might be able to serve libs already in the local cache

vemv 2023-08-26T19:06:05.837319Z

Yes, I understand those principles, and in particular that there isn't a hard-and-fast way to determine the cause of a failure. However by including the :mvn/repos in the ex-data, users can make a more educated guess of what's going on.

Alex Miller (Clojure team) 2023-08-26T19:19:52.531269Z

well, I think you're probably wrong because no one actively looks at the ex-data

vemv 2023-08-26T19:20:56.644139Z

IDK, we Clojurists are a diverse and generally smart bunch :)

Alex Miller (Clojure team) 2023-08-26T19:52:35.314259Z

well that is true

vemv 2023-08-26T15:31:33.420609Z

Does the clojure.tools.deps ns have a function that given a "-M:what:ever" , will return (or at least include somewhere) the main program that will be executed? i.e. the name of the underlying java class

Alex Miller (Clojure team) 2023-08-26T15:56:23.556439Z

https://clojure.github.io/tools.deps/#clojure.tools.deps/create-basis is really the primary entry point now and it takes :aliases vector. all merged and resolved alias options will be in the :argmap of the return map

Alex Miller (Clojure team) 2023-08-26T15:57:55.723309Z

so (-> (create-basis {:aliases [:what :ever]}) :argmap :main-opts) should be something like ["MainClass" ...]

🤔 1
vemv 2023-08-26T19:33:19.879829Z

Thanks! I got it working