tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
2020-10-08T15:41:02.255400Z

Does anyone know if https://clojure.atlassian.net/browse/TDEPS-163 is likely to be implemented any time soon?

alexmiller 2020-10-08T15:44:44.256900Z

probably not, but I did think more about it - the time when it's read by clj is in tools.deps.alpha, which is the process that builds the classpath. at that point you don't have any deps on the classpath (b/c that's what you're making). so it is more complicated than it initially appeared.

ghadi 2020-10-08T15:45:07.257200Z

catch 22

2020-10-08T15:45:30.257500Z

ahh so the data-readers aren’t even available yet?

alexmiller 2020-10-08T15:45:41.257800Z

no

alexmiller 2020-10-08T15:46:18.258600Z

tools.deps could do what's in the ticket, and that would open that up for library use of tools.deps. but it won't help you via clj.

2020-10-08T15:48:31.259500Z

not sure I understand. Would it not be possible to read it with a :default reader in the first pass, and then re-read it later when you have that info?

borkdude 2020-10-08T15:52:20.260200Z

@alexmiller With regards to env vars your reasoning was: the less tools have to know, the better it is. Doesn't that also go for reader tags?

borkdude 2020-10-08T15:55:09.260900Z

when opening up reader tags, one could implement one which reads env vars (or wait, it was resolving your home dir), which brings the same trade-offs maybe

alexmiller 2020-10-08T15:57:09.261Z

no? you would need to start a whole new jvm to do that

alexmiller 2020-10-08T15:57:28.261300Z

yeah

2020-10-08T16:00:35.262200Z

Yeah I guess it makes sense not to do it then, thanks for considering it though 🙇

vlaaad 2020-10-08T16:08:47.262800Z

what if reading tags is done with tagged-literal?

vlaaad 2020-10-08T16:09:22.263500Z

and then basis can be read with proper reader tags when there is a classpath..

vlaaad 2020-10-08T16:10:19.264Z

What’s the problem reader tags are supposed to solve though?

2020-10-08T16:14:44.264400Z

giving a data representation to otherwise un(print|read)able things.

2020-10-08T16:24:07.271800Z

So my use case is essentially: I’m using integrant to define systems of components. Those systems are typically wired together in a base.edn file on the classpath. That file contains a map of integrant components. However it would be useful to override some parts (key/values) in the integrant system via the command line, and start the thing with clojure -X Or in prodution allow a user to specify their own profiles as :exec-args data in the deps.edn file directly. One of the things you may want to override though is an #ig/ref which basically states this component depends on this other component. My current example is a program that I want to communicate with two different deployments of the same system. One of which is authenticated via an auth0 provider, the other is identical but authenticated via a basic auth provider. I was hoping tagged reader support in the cli tooling would help with this; but it seems I’ll need to implement something to do this. It’s not too complicated; but it’s something I could use in a lot of projects, so I was hoping I could just leverage the cli tools rather than reimplement it each time; or require a library function to do it.

alexmiller 2020-10-08T16:50:14.276Z

You can read the deps.edn yourself and have any data you like in the aliases

2020-10-09T09:00:30.320300Z

I’d be happy to do that, but it would also be useful if the cli tools didn’t choke on it:

{:aliases {:reader {;;:exec-fn foo/bar
                    :exec-data {:tag #foo [some stuff]}}
           }}
$ clj -X:reader
Error building classpath. Error reading edn. No reader function for tag foo (/Users/rick/tmp/deps.edn)
If they could set :default to clojure.core/tagged-literal this way would I think work for me. Is that what you mean by this? > A good problem would be to avoid any error like that while computing the classpath from the deps. > That I would be happy to do

2020-10-09T09:01:14.320500Z

ahh also seen @vlaaad appears to be suggesting this :thumbsup:

vlaaad 2020-10-09T09:02:22.320800Z

yep, that’s what I suggested

1👍
2020-10-09T09:03:27.321100Z

Yeah it’s also what I actually meant here: https://clojurians.slack.com/archives/C6QH853H8/p1602172111259500

2020-10-09T09:04:08.321400Z

Though I see now it wasn’t clear

alexmiller 2020-10-09T13:03:01.322400Z

I actually made this change yesterday in tools.deps https://github.com/clojure/tools.deps.alpha/commit/17f036429b28537c5bb83878cea1c4322fe21d15

alexmiller 2020-10-09T13:04:12.323900Z

Oh, I didn’t change it for -X param reading though, I’ll get that too before the next release

vlaaad 2020-10-09T13:15:15.324100Z

oh, that’s great!!!

vlaaad 2020-10-09T13:29:23.324300Z

#clj/requiring-resolve foo.bar/baz here I come

1
2020-10-09T13:30:52.324600Z

Ahh fab! Thanks @alexmiller 🙇

vlaaad 2020-10-09T13:44:28.324900Z

Or bringing #= to edn with #clj/eval (some-code)

1
alexmiller 2020-10-08T16:51:04.277100Z

A good problem would be to avoid any error like that while computing the classpath from the deps.

alexmiller 2020-10-08T16:51:24.277500Z

That I would be happy to do

vlaaad 2020-10-08T16:51:46.277700Z

Hmm, agree, supplying non-data args via -X is complicated. My api functions in Reveal are supposed to only accept functions as arguments, but to make them available from clj-exec, I have to accept symbols as well and introduce polymorphism just to satisfy clj-exec: https://github.com/vlaaad/reveal/blob/master/src/vlaaad/reveal.clj#L11

vlaaad 2020-10-08T16:52:37.277900Z

If deps supported tagged literals, I wouldn't have to pollute my api

ghadi 2020-10-08T16:53:41.278300Z

there is no straightforward way to do it. I wouldn't gate yourself on deps

dharrigan 2020-10-08T17:48:18.280200Z

I'm curious - what is the caching strategy used for looking up dependencies - I know that a particular dependency has been updated, it shows on clojars, but referencing it as 'RELEASE' in the deps.edn (my main deps.edn, i.e., $HOME/.clojure/deps.edn) I can see that it it's not being pulled down.

2020-10-08T17:48:51.280500Z

use real versions

borkdude 2020-10-08T17:49:20.281400Z

@dharrigan it's a simple string hash on the user deps.edn, args and local deps.edn. Use -Sforce to update

dharrigan 2020-10-08T17:50:17.282800Z

Sure, I could do that - but I see for example in the popular seancorfield deps.edn, a lot of references to RELEASE as well. I mean it's not wrong to use RELEASE, it is supported. So surely, something must eventually attempt to find out if it is the latest release or not?

2020-10-08T17:50:39.283600Z

it is wrong

borkdude 2020-10-08T17:51:02.284300Z

RELEASE is something that maven supports, but it's not encouraged by deps.edn, it just works because it works in maven. They will deprecate it.

2020-10-08T17:51:10.284400Z

RELEASE is a mutable reference

2020-10-08T17:51:34.284800Z

building caching on top of that is terrible, and clj relies on caching

dharrigan 2020-10-08T17:52:24.285500Z

Okay, fairy enough. I will use the version, not release 🙂

2020-10-08T17:52:54.286Z

RELEASE is an easy vs. simple thing where people consistently choose what is easy

dharrigan 2020-10-08T17:53:03.286200Z

Indeed 🙂 We're all lazy 🙂

dharrigan 2020-10-08T17:53:23.286700Z

$deity knows I didn't become a programmer to be active 🙂

alexmiller 2020-10-08T17:53:26.286800Z

RELEASE is not officially supported by clj

alexmiller 2020-10-08T17:53:36.287100Z

use at your peril (it breaks the cache)

dharrigan 2020-10-08T17:54:26.288500Z

tbf, it (this library) was the only one in my deps.edn that has release for the coordinate

alexmiller 2020-10-08T17:54:33.288800Z

imo you should only ever use it in -Sdeps on the command line, not in a deps.edn file. I reserve the right to enforce that opinion at an arbitrary future time :)

borkdude 2020-10-08T17:55:24.289200Z

it's on the list for clj-kondo warnings here: https://github.com/borkdude/clj-kondo/issues/945

dharrigan 2020-10-08T17:56:03.289900Z

Something else, does deps use the .m2/settings.xml at all?

alexmiller 2020-10-08T17:56:20.290300Z

yes, for some things (like server creds, mirrors, proxies)

dharrigan 2020-10-08T17:56:26.290500Z

right right, good. thanks 🙂

alexmiller 2020-10-08T17:56:44.291Z

see https://clojure.org/reference/deps_and_cli#_maven

2020-10-08T17:56:55.291300Z

proxies for fetching maven deps, not for git deps?

alexmiller 2020-10-08T17:57:03.291500Z

yes, that is still a todo

alexmiller 2020-10-08T17:57:17.291800Z

there is a ticket for it, iirc

alexmiller 2020-10-08T17:57:58.292400Z

https://clojure.atlassian.net/browse/TDEPS-124

borkdude 2020-10-08T17:58:03.292600Z

deps.clj has support for http / https proxy settings: https://github.com/borkdude/deps.clj - not sure if that's what you mean https://github.com/borkdude/deps.clj#proxy-environment-variables

borkdude 2020-10-08T18:01:27.293700Z

I think it works in deps.clj because the proxy settings are also passed to the make-classpath invocation

alexmiller 2020-10-08T18:02:12.293900Z

that would make sense

dpsutton 2020-10-08T18:12:27.295Z

i can get the version from clojure by running clojure --help but it prints with lots of other text obviously. is there a way to get just the version?

dpsutton 2020-10-08T18:13:05.295900Z

we have a script that invokes -m and wondering whether its better to omit the -M and get a warning or include it and break usage for people who are on older versions

alexmiller 2020-10-08T18:14:23.296300Z

clj -Sdescribe will return edn content that includes a :version key

borkdude 2020-10-08T18:14:42.296600Z

@dpsutton

$ clojure -Sdescribe | jet --query :version
"1.10.1.697"

1👍
alexmiller 2020-10-08T18:15:03.297Z

note that the warnings are on stderr so you can redirect stderr to null too if you want to not see those

borkdude 2020-10-08T18:16:00.297200Z

$ clojure -Sdescribe | clojure -M -e "(require '[clojure.edn :as edn]) (:version (edn/read *in*))"
"1.10.1.697"

borkdude 2020-10-08T18:16:37.297400Z

$ clojure -Sdescribe | bb '(:version *input*)'
"1.10.1.697"
ok, I'm done now :)

alexmiller 2020-10-08T18:16:40.297600Z

heh

alexmiller 2020-10-08T18:17:04.297900Z

but I have all these cat skins lying about...

borkdude 2020-10-08T18:18:54.298100Z

k, one more:

$ clojure -Sdescribe | grep :version | cut -d' ' -f2
"1.10.1.697"

lread 2020-10-08T18:25:43.300700Z

@dpsutton, I’ve moved to the new clojure command line syntax for rewrite-cljc. I have its scripts fail with an error message if clojure version < 1.10.1.697. My scripts are all in babashka so the check was easy.

1👍
dpsutton 2020-10-08T18:30:52.301Z

thanks everyone

dharrigan 2020-10-08T18:38:27.301900Z

w00t. It will certainly help those coming fresh to Clojure and seeing your excellent deps.edn example.

seancorfield 2020-10-08T18:42:33.303400Z

Or the Practicalli example (nicer web site, more descriptive names, much better documentation). I'm considering linking to it from my dot-clojure repo and encouraging new folks to use the Practicalli stuff instead -- so I'm under less pressure to keep dot-clojure maintained and documented 🙂

1👍
practicalli-john 2020-10-08T21:29:48.305200Z

@seancorfield I would be honoured to be linked from your repo. Thank you. The library versions used in the Practicalli aliases are updated at least once a month using the :project/outdated alias and version changes added to the changlog. Versions are updated sooner if I spot a new version or a library maintainer let's me know.

1👍
seancorfield 2020-10-08T21:39:18.306400Z

seancorfield/depstar {:mvn/version "1.1.126"} -- https://github.com/seancorfield/depstar/releases/tag/v1.1.126 -- just three small bug fixes; follow-up in #depstar

seancorfield 2020-10-08T22:00:09.312300Z

I was planning to make -X the preferred way of using depstar in that release but I realized that -X:uberjar ends up putting the Clojure CLI's version of tools.deps.alpha into the JAR file -- because depstar assumes the "current classpath" is what you want in the JAR (and it excludes itself, assuming it is the only dependency you don't want in the JAR). -X:jar works just fine (because it excludes JAR files). I'll need to modify depstar to use t.d.a directly to build a classpath from deps.edn files (per the discussion the other day) but that gets complicated if you need a "user" deps.edn file and you're using CLJ_CONFIG with a monorepo -- as we are at work -- so that will have to wait for "depstar 2". Given the discussions around that and t.d.a itself recently in this channel, I'll probably defer that work until t.d.a has better support for that (since CLJ_CONFIG is part of the clojure script, not t.d.a).

seancorfield 2020-10-08T22:01:23.313Z

BTW, CLJ_CONFIG is documented officially (I thought it wasn't):

User - cross-project configuration (typically tools)

Locations used in this order:

If $CLJ_CONFIG is set, then use $CLJ_CONFIG (explicit override)
https://clojure.org/reference/deps_and_cli#_deps_edn_sources

2020-10-08T22:13:32.315400Z

Is it possible to ignore a project’s deps.edn when invoking clojure cli? It would sometimes be useful when passing -Sdeps, e.g. in a tool that bumps a project’s version, or builds docs.

seancorfield 2020-10-08T22:14:15.315800Z

@hugod Yes, that's what :replace-deps is for.

2020-10-08T22:15:59.317100Z

thank you - I was looking for a command line switch

seancorfield 2020-10-08T22:16:24.317600Z

You can use it in -Sdeps but you'd need an alias I believe.