tools-deps

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

working to give an error message to verify that the tools deps version is too old to support -M -m. Does anyone know offhand if a version supported -X but not -M -m? Hoping can check something real quick with -X and that means it necessarily supports -M

dpsutton 2020-10-29T15:44:24.138Z

as it stands, added a simple (ns check) (defn -main [& _] (System/exit 0)) but would prefer to not need a new main and new ns if X and M go hand in hand

dpsutton 2020-10-29T16:27:38.138500Z

ie, could just do clojure -X clojure.core/identity :a :a and if that returns 0 then good to go for -M -m our.stuff

lread 2020-10-29T16:38:01.140700Z

@dpsutton I expect this is not what you are looking for, but I write my scripts in Babashka where I find a Clojure version check to be explicit and straightforward: https://github.com/lread/rewrite-cljc-playground/blob/60ad8c118a86221e35692f2ce10281e7cef0f8a4/script/helper/env.clj#L39

practicalli-john 2020-10-29T16:39:10.141400Z

@dpsutton https://clojure.org/releases/tools might have the info about -X but not -M -m support... although I believe -X support wasnt added until https://clojure.org/releases/tools#v1.10.1.697 and -M -m was in by then. I use https://clojure.org/releases/tools#v1.10.1.697 as the minimum requirement for Clojure CLI tools with my aliases and content from Practicalli

seancorfield 2020-10-29T16:42:41.142200Z

-M has been in the CLI for a long time but it's meaning changed around 1.10.1.697

seancorfield 2020-10-29T16:43:45.143500Z

The difference between 1.10.1.561 (stable) and the later version is just that -M now respects resolve-args and classpath-args in aliases as well as main-opts. Previously, it ignored resolve-args and classpath-args. Does that help @dpsutton?

dpsutton 2020-10-29T16:45:30.144500Z

Yeah that does. I think that means we should use the check for X support to make sure we have a recent enough version

dpsutton 2020-10-29T16:45:59.145300Z

Although I think our use case is simple enough that as long as M support is there it’s fine

seancorfield 2020-10-29T16:59:22.146200Z

@dpsutton I just ran some tests on a bunch of prerelease versions between the last two stable releases, and there are several where that command returns a zero status but doesn't actually work.

seancorfield 2020-10-29T17:00:26.146800Z

(but I believe they would support -M with aliases by that point... I just haven't tested that 🙂 )

dpsutton 2020-10-29T17:02:00.147100Z

In what way do they not work?

dpsutton 2020-10-29T17:02:09.147500Z

And thanks so much!

seancorfield 2020-10-29T17:02:40.147700Z

(! 1626)-> /usr/local/Cellar/clojure\@1.10.1.636/1.10.1.636/bin/clojure -X clojure.core/identity :a :a
No alias specified with -X

Thu Oct 29 09:58:15
(sean)-(jobs:0)-(/Developer/workspace/wsmain/build)
(! 1627)-> echo $?
0

seancorfield 2020-10-29T17:03:13.148300Z

The ability to pass the fn to execute on the command-line came fairly late in that set of prerelease builds.

seancorfield 2020-10-29T17:04:28.148700Z

1.10.1.672 seems to be the first prerelease build that allowed it.

dpsutton 2020-10-29T17:05:18.149500Z

Oh ok. It’s only prereleases? If so they can diagnose it on their own :)

dpsutton 2020-10-29T17:05:40.150Z

Bleeding edge is sometimes bleeding

seancorfield 2020-10-29T17:06:13.150500Z

Yeah, 1.10.1.561 (previous stable) throws an exception and gives a non-zero exit status.

seancorfield 2020-10-29T17:06:31.151400Z

(so does 1.10.1.590 which was the first of the prerelease builds)

dpsutton 2020-10-29T17:06:40.151800Z

Beautiful. How do you change versions so quickly? Would have done that if I knew a good way to swap them around easily

seancorfield 2020-10-29T17:07:46.152400Z

I installed them by version with brew and then I can use the full path (as shown above) to run any version I want 🙂

seancorfield 2020-10-29T17:07:58.152600Z

clojure@1.10.1.561/ clojure@1.10.1.641/ clojure@1.10.1.697/
clojure@1.10.1.590/ clojure@1.10.1.645/ clojure@1.10.1.708/
clojure@1.10.1.596/ clojure@1.10.1.672/ clojure@1.10.1.716/
clojure@1.10.1.619/ clojure@1.10.1.681/ clojure@1.10.1.723/
clojure@1.10.1.636/ clojure@1.10.1.693/ clojure@1.10.1.727/

kirill.salykin 2020-10-29T17:08:29.153500Z

how are you doing this?

seancorfield 2020-10-29T17:08:34.153800Z

I didn't have 561 until just now, but installed it by version to test.

kirill.salykin 2020-10-29T17:09:01.154400Z

just brew install @version ?

seancorfield 2020-10-29T17:09:09.154600Z

brew install clojure/tools/clojure@1.10.1.561 per the CLI install docs

kirill.salykin 2020-10-29T17:09:31.155200Z

clear, thanks a lot!

seancorfield 2020-10-29T17:10:09.155400Z

See https://github.com/clojure/homebrew-tools (which is linked from the CLI install docs on the CLI guides page)

dpsutton 2020-10-29T17:14:30.156100Z

Oh I didn’t know it left older versions laying around