tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
seancorfield 2020-09-07T00:46:47.483Z

Can't you override it to point to local JAR? The sources JAR file?

seancorfield 2020-09-07T01:25:38.483800Z

Since we're getting a lot of depstar questions here, I created a dedicated channel for support/questions/etc. Also for clj-new.

borkdude 2020-09-07T06:59:22.485700Z

@dominicm you can also use classpath overrides with nil. I’ve used this for creating babashka uberjars (see its README and look for uberjar)

kirill.salykin 2020-09-07T09:53:33.486400Z

goodmorning, please advice how I can turn off the OmitStackTraceInFastThrow?

clojure -A:app -J "XX:-OmitStackTraceInFastThrow"
doesnt seem to work

dharrigan 2020-09-07T09:54:32.486700Z

clojure -J-XX:-OmitStackTraceInFastThrow

kirill.salykin 2020-09-07T09:54:46.486900Z

thanks! it is all about the order

dharrigan 2020-09-07T09:55:04.487200Z

np

practicalli-john 2020-09-07T10:28:42.489300Z

In clojure pre-release (1.10.1.672) it seems that the -X flag does not download dependencies specified in the alias :extra-deps section. Is this the correct behavior? From my interpretation of "-X now supports multiple aliases, aliases with other argmap options like :extra-deps, and ad hoc functions" I would have thought deps would be downloaded

borkdude 2020-09-07T10:29:30.489500Z

is that in combination with -A?

practicalli-john 2020-09-07T10:29:59.489800Z

No, just by itself. I understood -A was being depreciated, so am trying to understand the scope of using -M (which seems fairly clear) and -X which I am still confused about (from a users ponit of view)

alexmiller 2020-09-07T13:30:58.490600Z

@jr0cket that is intended to work, so could be a bug

2020-09-07T13:45:26.492500Z

To temporarily swap out a git dep for a local dev version, am I normally better adding an alias with :override-deps in it to a :local/root, or adding :classpath-overrides to my ~/.clojure/deps.edn ?

dominicm 2020-09-07T13:48:24.493700Z

@rickmoynihan I usually use an override-deps (actually extra-deps because it's the same otherwise) in ~/.clojure/deps.edn because: • Nobody else can use it - has my homedir in • Most people on my teams aren't contributing to those other libraries anyway. It's less reusable than one would think

2020-09-07T13:50:25.494600Z

yeah for both options I’m talking about adding it to ~/.clojure/deps.edn… trying to understand which way is better.

2020-09-07T13:51:11.495100Z

One (`:override-deps`) effects resolve-deps and the other make-classpath right?

2020-09-07T13:52:09.496Z

Practically though; aren’t they both equivalent?

dominicm 2020-09-07T13:52:16.496300Z

I think for your case, they're essentially equivalent. I'd go with extra-deps just because it's more famiilar.

2020-09-07T13:53:34.497Z

except :classpath-overrides assumes the lib only introduces a single classpath root, is that right?

2020-09-07T13:54:06.497500Z

so e.g. it would potentially miss including resources etc

dominicm 2020-09-07T13:55:13.498Z

Exactly, yeah

borkdude 2020-09-07T14:55:50.499800Z

Re command line args, I have one tool that only has one CLI argument, --opts in which you pass a Clojure map. For that tool I think it made sense and it also simplified command line parsing, possibly also easier to keep it non-breaking. I'm not suggesting that other tools do this, but works for this one particular thing.

clojure -A:carve --opts '{:paths ["src" "test"]}'

dominicm 2020-09-07T15:03:25.000500Z

I suppose the clj way of doing that is would be clj -X:carve :paths '["src" "test"]'?

borkdude 2020-09-07T15:04:22.000900Z

I guess so, but if we're going to use quotes, why not quote the whole thing anyway

dominicm 2020-09-07T15:05:14.001900Z

I mention it only because I think this is what clj is trying to make the standard for cli tools. While I personally think --path src --path test would be the best, standards are better than better.

borkdude 2020-09-07T15:08:32.002800Z

or :paths src,test since comma is whitespace in Clojure, but not in bash?

borkdude 2020-09-07T15:08:54.003100Z

$ bb -e "*command-line-args*" -- :paths src,test
(":paths" "src,test")

dominicm 2020-09-07T15:09:40.004Z

You're thinking in Clojure 🙂 I'm thinking of bash. Admittedly, my answer was without context. Generally I'd much prefer an api where paths was the & args at the end so I could just do:

clj -X:carve dev-*

dominicm 2020-09-07T15:09:59.004400Z

(which expands to clj -X:carve dev-src dev-resources dev-etc)

borkdude 2020-09-07T15:12:18.005300Z

If bash would expand that comma separated, then it would work as passing one value.

borkdude 2020-09-07T15:12:42.005600Z

Anyway, it doesn't.

borkdude 2020-09-07T15:14:06.006500Z

Yeah, if keywords would separate other values then :jars *.jar :paths src* would work

borkdude 2020-09-07T15:14:30.007Z

unless your dir starts with a colon :)

borkdude 2020-09-07T15:15:55.007500Z

but I guess using a comma as explicit separator works:

$ bb -e "*command-line-args*" -- :foo t* , :nums 1 2 3
(":foo" "tags" "test" "test-resources" "," ":nums" "1" "2" "3")

borkdude 2020-09-07T15:21:41.008100Z

This doesn't work in powershell (no expansion, comma is gone)

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Ubuntu-20.04\tmp> cd C:/Temp
PS C:\Temp>  bb -e "*command-line-args*" -- :foo t* , :nums 1 2 3
(":foo" "t*" ":nums" "1" "2" "3")

borkdude 2020-09-07T15:22:25.008400Z

Finally, cmd.exe (no expansion, preserves comma)

C:\Temp>bb -e "*command-line-args*" -- :foo t* , :nums 1 2 3
(":foo" "t*" "," ":nums" "1" "2" "3")

practicalli-john 2020-09-07T15:24:27.008700Z

Yes, it does work on a clean install of Clojure CLI with the ~/.clojure/.cpcache removed. This is making much more sence now. Thanks.

dominicm 2020-09-07T15:36:41.009400Z

No idea how cmd.exe handles wildcards. Ultimately there's some platform specific tweaks to match the ergonomics of a platform you're on.

dominicm 2020-09-07T15:37:44.010Z

https://docs.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments?view=vs-2019 apparently you have to use a custom routine or something... gosh

borkdude 2020-09-07T15:38:41.010300Z

I guess there's a reason WSL2 is getting popular

dominicm 2020-09-07T15:40:49.011Z

But also - this is what people on cmd.exe expect. That's fine and while I don't understand it, if that's what makes sense for their OS then fine.

borkdude 2020-09-07T15:42:22.011800Z

I listened to a podcast by someone who is working on the new Terminal app. She said that they couldn't change cmd.exe's behavior because that would be breaking for lots of people. But everyone basically agrees that it sucks.

borkdude 2020-09-07T15:43:41.012300Z

Making the cmd.exe window smaller will make it faster, because there is less rendering, which is blocking

borkdude 2020-09-07T15:44:04.012700Z

ok sorry, got a little bit off topic

practicalli-john 2020-09-07T15:52:28.012800Z

Forgetting migration for a moment, would you see :exec-fn and :exec-args replacing :main-opts in the long term? Using these new keys seems a nicer approach for the design of the alias code itself. Would this be an example of edn over strings that Alex mentions?

seancorfield 2020-09-07T16:47:43.013100Z

I think we'll see a good uptake on the :exec-fn approach because you can avoid parsing strings to get your arguments and you can easily provide defaults -- configurable defaults, since each alias have have its own :exec-args map.

lread 2020-09-07T17:49:16.016700Z

Getting back to clojure/clj command line arg compatibility, this is not helpful right now, but I am curious. If we could go back in time would these tools have been better initially named something like clj-alpha1 and clojure-alpha1? This would have drawn attention to their alpha-ness and also allowed a path for introducing breaking changes.

lread 2020-09-07T17:51:28.017300Z

Then again maybe not… this would have implied clojure itself is alpha.

lread 2020-09-07T17:51:43.017500Z

Tricky little problem.

borkdude 2020-09-07T17:55:02.018500Z

The help could have mentioned the word alpha at least somewhere. From and end user's perspective, it's hard to see this is alpha, you'd have to know what .jar it's calling underneath which has alpha in the name. This entire page doesn't mention alpha neither: https://clojure.org/guides/deps_and_cli

seancorfield 2020-09-07T17:59:08.022600Z

I just got a bug report against the new version of clj-new and it's obviously broken but it leads me to a question about t.d.a and migrations: clj-new uses t.d.a to resolve coordinates for templates and it was using t.d.a 0.8.677 and the clojure.tools.deps.alpha.reader namespace with default-deps and read-deps. I updated it to 0.9.782 and switched the code over to pull in the runtime basis... but of course that doesn't exist in the new CLI! Doh! I could revert to 0.8.677 and continue using the old logic, but I was wondering if there was a way in 0.9.782 to get at that same logic so that utilities could run with the basis, if it exists, else fall back to the equivalent of (read-deps (default-deps))? Mostly a question for @alexmiller I guess...

alexmiller 2020-09-07T18:15:58.023500Z

Those functions now exist in the tools.deps.alpha namespace

alexmiller 2020-09-07T18:16:18.024400Z

Or their equivalents - there were some name changes etc

seancorfield 2020-09-07T18:18:22.025600Z

Hmm, it looks like some of the logic for finding deps.edn has moved into the CLI script, and is no longer in t.d.a?

alexmiller 2020-09-07T18:18:49.026300Z

No, should all be there

alexmiller 2020-09-07T18:19:00.026800Z

Shape is a little different

seancorfield 2020-09-07T18:19:06.027Z

OK, I'll keep digging...

alexmiller 2020-09-07T18:19:50.027600Z

Sorry, not at a computer to be precise

alexmiller 2020-09-07T18:21:00.028700Z

It’s just root-deps and user-deps and ./deps.edn

alexmiller 2020-09-07T18:21:23.029Z

Read and merge

seancorfield 2020-09-07T18:32:54.029500Z

find-edn-maps was what I needed so I think I'm good now...

seancorfield 2020-09-07T18:52:23.032Z

For anyone else working on t.d.a-based tooling who wants to leverage 0.9.782 but continue to support older CLI versions, here's what I ended up with for the basis:

(delay (if-let [basis-file (System/getProperty "clojure.basis")]
           (-> basis-file
               (io/file)
               (slurp)
               (edn/read-string))
           (let [{:keys [root-edn user-edn project-edn]} (deps/find-edn-maps)]
             (deps/merge-edns (filterv some? [root-edn user-edn project-edn]))))))
That's to replace the equivalent of (read-deps (default-deps)) from t.d.a 0.8.677 -- it's not identical, but for the purposes of equivalence with 0.8.677 it seems close enough.

2020-09-07T23:05:42.032100Z

i have a tool that does something similar -- though it doesn't use anything like --opts before the string. it's nice to not have to decide on command line arguments when you don't know what option and arg names are likely to be used more often.