tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
alexmiller 2020-12-08T04:03:51.288300Z

I released clj 1.10.1.754 tonight, which has a bug fix for -Stree from yesterday and updates the windows scripts. If anyone wanted to give it a try I can promote it to stable. You should see new format for clj -Stree and same for clj -X:deps tree (see https://clojure.github.io/tools.deps.alpha/clojure.tools.cli.api-api.html#clojure.tools.cli.api/tree for more options)

seancorfield 2020-12-08T04:32:55.289900Z

I updated my two dev systems and tested on a few projects, looks good. Updated the work system and ran -Stree against a few of our subprojects, looks good. @alexmiller

đź‘Ť 1
onetom 2020-12-08T04:37:32.291Z

is it possible to run multiple functions via clojure, using multiple -X options?

alexmiller 2020-12-08T04:38:11.291200Z

no

đź‘Ť 1
alexmiller 2020-12-08T04:38:42.291700Z

once you do -X, all args afterwards go to the function you're running

seancorfield 2020-12-08T04:44:43.292300Z

@onetom You could always do -e "(do (invoke-fn1) (invoke-fn2))" 🙂

đź‘Ť 1
seancorfield 2020-12-08T04:45:01.292700Z

(well, using requiring-resolve for each function)

alexmiller 2020-12-08T04:55:55.292900Z

A new version of the clojure tools is now available (https://clojure.org/releases/tools#v1.10.1.754) • New, more informative tree format for `clj -Stree` / `clj -X:deps tree` • Added https://clojure.github.io/tools.deps.alpha/clojure.tools.cli.api-api.html#clojure.tools.cli.api/tree for use with `clj -X:deps tree` • Use https://github.com/clojure/tools.deps.alpha/blob/master/CHANGELOG.md 0.9.857

alexmiller 2020-12-08T04:56:17.293400Z

winding it's way through the homebrew tubes

onetom 2020-12-08T05:06:53.294700Z

1st attempt via a Nix derivation:

: clj -X:deps tree
Downloading: org/clojure/tools.deps.alpha/0.8.677/tools.deps.alpha-0.8.677.pom from central
Downloading: org/clojure/tools.deps.alpha/0.8.677/tools.deps.alpha-0.8.677.jar from central
Unqualified function can't be resolved: tree
: which clj
/nix/store/g7cpwnmzfl9ikxnm7gbnq3qqgj0mynwk-clojure-1.10.1.754/bin/clj

seancorfield 2020-12-08T05:08:28.296100Z

@alexmiller I notice that mvn-pom takes an argument argmaps as a vector of aliases -- I understand why it's called that but it's... less than ideal 🙂 aliases seems like a more intuitive name if we're going to standardize on a way to provide a list of aliases to tooling?

seancorfield 2020-12-08T05:09:09.297Z

(is the tree function possibly going to take an aliases (or argmaps) argument so we can see trees based on, say, test dependencies?)

onetom 2020-12-08T05:09:14.297100Z

clj -Stree seems to work though. it has nice X-es and dots in front of the dependency names

seancorfield 2020-12-08T05:10:11.297300Z

@onetom Sounds you have a :deps aliases that doesn't come from the system deps.edn file?

seancorfield 2020-12-08T05:10:56.297600Z

That version of t.d.a is old.

seancorfield 2020-12-08T05:11:12.297800Z

The new CLI uses 0.9.857

seancorfield 2020-12-08T05:12:00.298Z

seanc@DESKTOP-30ICA76:~/oss$ clojure -A:deps -Stree
org.clojure/clojure 1.10.1
  . org.clojure/spec.alpha 0.2.176
  . org.clojure/core.specs.alpha 0.2.44
org.clojure/tools.deps.alpha 0.9.857

onetom 2020-12-08T05:13:08.298200Z

i know it's the old one, that's why im surprised and showed what happened.

seancorfield 2020-12-08T05:13:35.298400Z

Like I said, you have a :deps alias in your user deps.edn I suspect.

onetom 2020-12-08T05:15:05.298600Z

ah, indeed. i probably copied it from your ~/.clojure/deps.edn

seancorfield 2020-12-08T05:25:35.298800Z

https://github.com/seancorfield/dot-clojure/commit/431a9f0ed6d763260bfa2c9b568f405b5bd59453 July 28th I changed that 🙂

đź‘Ť 1
1
onetom 2020-12-08T05:52:25.301300Z

I saw in https://clojure.org/reference/deps_and_cli there is a :default-deps option for factoring out version info for common dependencies. What's the recommended way to provide that option from a central location? (Something like https://github.com/walmartlabs/shared-deps is for lein)

seancorfield 2020-12-08T05:54:08.302900Z

@onetom There are only three deps.edn files: the system (that you can't touch), your user file (in ~/.clojure), and your project file.

onetom 2020-12-08T05:54:16.303100Z

i see and can probably do clj -Sdeps $(cat ../default-deps.edn) ..., but can i do that at some more fundamental level?

seancorfield 2020-12-08T05:54:50.303500Z

:default-deps only works in an alias BTW, as does :override-deps

đź‘Ť 1
onetom 2020-12-08T05:55:13.303600Z

i thought about using CLJ_CONFIG to override the per-user default within project environments, but that would also prohibit developers to access their personal tools...

seancorfield 2020-12-08T05:55:50.303900Z

We used to do that. It "works" but it introduces all sorts of problems regarding tools. We stopped doing that.

onetom 2020-12-08T05:57:03.304100Z

so do you require your devs so define certain aliases in their ~/.clojure/deps.edn in order for the walmart projects to work or that's the thing you mean you stopped doing?

onetom 2020-12-08T05:57:54.304300Z

i for example moved the ion-dev deps into the project's own deps.edn because we were accidentally using an older version on one of the machines and it failed in mysterious ways...

onetom 2020-12-08T05:58:41.304500Z

i just don't want to keep copy-pasting a lot of "boilerplate" setup, while we are in a monorepo, where it could be just centralized.

seancorfield 2020-12-08T05:58:42.304700Z

Unfortunately, there's no "good" solution for monorepos at this point. Or, more generally, for providing "shared project deps". Feel free to upvote this issue https://ask.clojure.org/index.php/9849/teams-common-dependencies-tooling-across-multiple-projects

đź‘Ť 1
seancorfield 2020-12-08T06:00:02.305100Z

We used to use the CLJ_CONFIG "hack". Now we're using a different "hack" that involves generating deps.edn from template files. Neither are good.

onetom 2020-12-08T06:05:12.305300Z

good to hear that "it's not just me" 🙂 the problem is that i don't even know what would a great solution look like... otherwise i would hack together something

alexmiller 2020-12-08T06:05:36.305500Z

both this and previous are again https://clojure.atlassian.net/browse/TDEPS-175

alexmiller 2020-12-08T06:05:52.305700Z

you can do this for now with -Stree

onetom 2020-12-08T06:05:56.305900Z

thanks for sharing the problem statement!

seancorfield 2020-12-08T06:06:39.306100Z

I think a reasonable solution is to be able to specify one-or-more additional deps.edn files that should be processed in this order: system -> user -> <specified deps.edn files in order> -> project deps.edn -> command-line -Sdeps

1
alexmiller 2020-12-08T06:06:52.306300Z

or you can use -Strace and whatever to create a trace.edn and feed it to -X:deps tree with :file

seancorfield 2020-12-08T06:06:53.306500Z

but that touches a lot of parts of tools.deps.alpha

seancorfield 2020-12-08T06:07:55.306700Z

Yeah, I know what the workarounds are 🙂

seancorfield 2020-12-08T06:08:04.306900Z

I'm asking about a "better future" 🙂

alexmiller 2020-12-08T06:08:27.307100Z

well, this is the same conversation we've already had, not sure what more you're looking for

seancorfield 2020-12-08T06:09:07.307300Z

I was at least hoping for a comment on the name of the argument, given our past conversations.

alexmiller 2020-12-08T06:09:31.307500Z

I'm not sure how to convey "haven't worked on it yet" more than previously :)

seancorfield 2020-12-08T06:09:57.307700Z

Fair enough. I was fishing for an opinion or a direction, that's all.

seancorfield 2020-12-08T06:10:56.307900Z

I mean, I'm about to do this for depstar so calling it :argmaps because that's what mvn-install uses is one approach, but calling it :aliases seems a bit more intuitive.

seancorfield 2020-12-08T06:12:34.308100Z

(one big "downside" to the exec stuff is that the names of arguments become part of the API so this is more important than it used to be)

2020-12-08T17:15:49.318400Z

I'm trying to build a clojure project in circleci and it depends on the cognitect-labs test-runner. This all works fine locally but when circleci tries to build, I get an authentication error when it tries to download dependencies. I've seen other folks with this problem and the solution is usually to fix the entry in deps.edn to use the "https:" pointer to the test-runner rather than the "git@" pointer but my project already does that. https://app.circleci.com/pipelines/github/cddr/test-machine/6/workflows/05e75093-3a28-438c-97b0-7bd0f9bc5132/jobs/6 I'm using the "clojure -P -M:runner" trick to download dependencies and save the cache before actually trying to run the tests and it seems to be at this point where it fails. Would you expect that to work ok? The code for the project itself is here: https://github.com/cddr/test-machine

2020-12-08T17:19:14.320900Z

Another question this has prompted is, where does clojure download repos it clones when a :git/url style dependency is used? Would be cool to delete previously downloaded repo in my local setup in order to test this locally without pushing to circleci each time I change something.

alexmiller 2020-12-08T17:20:03.321900Z

You may have an insteadOf rule in your ci git config that is forcing ssh urls

2020-12-08T17:21:23.323500Z

Ah interesting. I'll try to verify that. Thanks for the hint

alexmiller 2020-12-08T17:21:37.323900Z

I have helped multiple people with the same problem

alexmiller 2020-12-08T17:22:27.324700Z

This swaps before clj even sees it

2020-12-08T17:23:34.325Z

circleci@518e1f74cd0a:~$ cat .gitconfig
cat .gitconfig
[url "<ssh://git@github.com>"]
	insteadOf = <https://github.com>
[gc]
	auto = 0
circleci@518e1f74cd0a:~$ 

2020-12-08T17:23:37.325200Z

right enough

alexmiller 2020-12-08T17:26:23.326300Z

Not sure if this is some recent change in default config

2020-12-08T17:30:19.328100Z

Yeah I'm using one of their pre-built base images containing tools.deps. I'll report back with where it sets this ~/.gitconfig if I can find it 🙂

practicalli-john 2020-12-08T18:12:55.329800Z

@cddr there is a discussion in #circleci on this very issue, with more details

borkdude 2020-12-08T18:18:04.330600Z

@cddr yep, had exactly the same issue. "fixed" it by adding rm -f ~/.gitconfig to my circleci builds

đź‘Ť 1
kirill.salykin 2020-12-08T18:34:45.332800Z

Hi is there a way to use paths/deps from an alias but skip the main-opts for instance, for this test alias

:test {:extra-paths ["test"]
         :extra-deps {lambdaisland/kaocha           {:mvn/version "1.0.690"}
                      lambdaisland/kaocha-cloverage {:mvn/version "1.0.63"}
                      lambdaisland/kaocha-junit-xml {:mvn/version "0.0.76"}
                      ring/ring-mock                {:mvn/version "0.3.2"}
                      mockery                       {:mvn/version "0.1.4"}
                      http-kit.fake/http-kit.fake    {:mvn/version "0.2.1"}}
         :main-opts  ["-m" "kaocha.runner"]}
is there a way to skip the main-opts ? It seems that it is being used and this fails cider-jack-in I am looking for analog of R/C in old syntax

seancorfield 2020-12-08T18:36:03.333800Z

@kirill.salykin The general recommendation is to separate that sort of thing into multiple aliases.

kirill.salykin 2020-12-08T18:36:16.334200Z

i see, thanks

seancorfield 2020-12-08T18:36:59.335500Z

So you have a :test alias with the deps/paths you need to access/run your test code in the REPL and a :runner alias that is the Kaocha deps :main-opts (and any additional deps needed)

kirill.salykin 2020-12-08T18:37:01.335600Z

is there are reason for such change? -R -C seemed quite useful to me

seancorfield 2020-12-08T18:37:09.335800Z

@alexmiller ^

borkdude 2020-12-08T18:38:32.337Z

^

seancorfield 2020-12-08T18:38:33.337100Z

I suspect cider-jack-in should be adding its own :main-opts after the :test alias (so that it "wins" in the merge process)

seancorfield 2020-12-08T18:40:08.338600Z

(I always start my REPL manually and then connect to it from my editor)

kirill.salykin 2020-12-08T18:40:33.338700Z

Indeed, this is exactly what happens

jack-in command: /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.5"}}}' -A:dev:test -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'

seancorfield 2020-12-08T18:40:53.338900Z

No, that's not what I meant.

kirill.salykin 2020-12-08T18:40:58.339100Z

oh

seancorfield 2020-12-08T18:41:10.339400Z

I literally meant :main-opts so that it is merged last and "wins"

borkdude 2020-12-08T18:41:35.340100Z

me too, never use cider-jack-in, don't want my editor to bring down the dev process, ever

practicalli-john 2020-12-09T11:10:49.354500Z

This is a good point I had not considered. This point and given the different opinions on how to resolve cider-jack-in with clojure cli tools, I will switch to cider-connect and update the book to use that as the main approach for anything but a beginning. I have all the aliases I need to connect CIDER, Calva and Conjure to a repl run in a terminal, and they are updated monthly. Thank you.

kirill.salykin 2020-12-08T18:41:37.340200Z

-A:test sets -m which seems conflicting with -m from the cider

kirill.salykin 2020-12-08T18:42:03.340800Z

ah, so we need to migrate anyway

seancorfield 2020-12-08T18:43:08.341Z

clojure -Sdeps '{:deps ... :aliases {:cider/jack-in {:main-opts ["-m" ...]}}}' -M:dev:test:cider/jack-in --middleware ...

seancorfield 2020-12-08T18:43:32.341200Z

Since there is no way to specify :main-opts without an alias (at least, not right now).

kirill.salykin 2020-12-08T18:43:44.341400Z

probably I should reach to cider people to discss this

kirill.salykin 2020-12-08T18:43:48.341600Z

thanks for help!

dpsutton 2020-12-08T18:44:11.341800Z

that's a clever idea. offhand do you know if that works for the past several versions of t.d.a?

dpsutton 2020-12-08T18:44:24.342Z

(don't research, just if you know off-the-cuff)

seancorfield 2020-12-08T18:44:42.342500Z

Which "that" are you asking about?

dpsutton 2020-12-08T18:45:06.342900Z

the main opts in the inline -Sdeps and last merged wins

seancorfield 2020-12-08T18:45:20.343100Z

That's always been the way :main-opts works in aliases.

dpsutton 2020-12-08T18:45:27.343300Z

awesome. thanks @seancorfield

seancorfield 2020-12-08T18:45:37.343500Z

(I assume you mean "Clojure CLI" not "t.d.a"?)

dpsutton 2020-12-08T18:46:14.343700Z

yes. i always blank on how to specifically refer to the command line stuff, not the language, not the library it is built on, etc

dpsutton 2020-12-08T18:46:44.343900Z

i'll go with Clojure CLI from now on

seancorfield 2020-12-08T18:49:12.344400Z

@dpsutton Mostly I nitpick on that because the versions of Clojure, the Clojure CLI, and the underlying t.d.a are all different.

kirill.salykin 2020-12-08T18:51:56.344600Z

> This is another case where I think `-R` should have been retained for “REPL” operations and expanded to include both resolve-args (old behavior) and classpath-args -- in the same way `-M` was expanded to include resolve-args and classpath-args -- in addition to just `:main-opts` (old behavior). And `-A` deprecated. That would have been an easier migration path for people. But that ship has sailed that would be ideal indeed

dpsutton 2020-12-08T18:52:02.344800Z

i appreciate it. i hope it didn't sound snarky. i always grasp for the right way to phrase it so thanks

practicalli-john 2020-12-08T22:41:27.350100Z

@kirill.salykin you can use an alias like :middleware/cider-clj in practicalli/clojure-deps-edn and a .dir-locals.el to switch off the auto-injection of cider dependencies, however it seems very strange to run two separate tools from one Clojure command, espcially as Kaocha does not interact with the REPL as I understand it, its only looking as the file system. This just seems weird I am afraid...

practicalli-john 2020-12-09T09:20:32.352700Z

The simplest approach is to have two aliases, one for test and one for a test runner. That is what I do any what I have seen from others. Defining specific is also more efficient, as you are only loading in libraries that you are actually using. Loading in kaocha and it's great many dependencies adds to startup time and also more potential for library version conflicts, especially on larger Clojure projects.

kirill.salykin 2020-12-09T09:22:41.352900Z

I understand that two separate aliases will work But I was looking for “-C” / “-R” analogs which allows you just pick paths/deps from the alias (now it is deprecating, so was asking how one can to do something similar with a new syntax)

practicalli-john 2020-12-09T09:23:48.353200Z

The issue you raise is easily solved, just add an alias that runs the nREPL.middleware to the end of the chain of aliases. I used your :test alias with the :middleware/cider-clj from my practicalli/clojure-deps-edn and Cider jack-in works without any issues

kirill.salykin 2020-12-09T09:24:02.353400Z

oke, thanks

practicalli-john 2020-12-09T09:28:57.353600Z

Or you can just set cider variables to switch the cider auto-inject off Nd just use whatever aliases you wish, so long as a cider one is last.

practicalli-john 2020-12-09T09:34:09.353800Z

On the command line, clojure -M:foo:bar:baz:lizard:spock would only run the main-opts from :spock even if all of the aliases have :main-opts configuration. Again this is simpler than having lots of different flags to remember.