Fork me on GitHub
#tools-deps
<
2021-07-29
>
Oliver George01:07:00

I'm curious to try Clojure CLI https://clojure.org/releases/tools#v1.10.3.933 - is there usually a delay before brew upgrade clojure/tools/clojure will find it? brew tells me "Warning: clojure/tools/clojure 1.10.3.822 already installed"

Oliver George01:07:40

I suspect my brew-fu is at fault. Perahps there's some tap specific update needed so brew knows about new releases.

seancorfield01:07:28

Maybe you just need to run brew update first @olivergeorge?

Oliver George01:07:47

Ta. I got there in the end. brew update didn't seem to help but doing a version specific brew install worked (at least clashed with what I had but after fetching the new version).

seancorfield02:07:24

Yeah, I always do the explicit @version install (and then the brew link dance)...

👍 3
Alex Miller (Clojure team)02:07:23

brew upgrade clojure/tools/clojure should work - it's updated there

Alex Miller (Clojure team)02:07:57

I'm still waiting on homebrew to merge to homebrew core

👍 3
flowthing06:07:37

> Thanks in particular for TDEPS-198! Seconded, many thanks!

dominicm09:07:41

I'm struggling to use -X:deps help/doc . I think it's my misunderstanding. It's unable to work because my tools are in a namespace that requires namespaces in a library, but -X:deps replaces the deps instead, so I get "Could not locate clojure/data/csv__init.class, clojure/data/csv.clj or clojure/data/csv.cljc on classpath.". Shouldn't -X:deps run as well as my project dependencies to make this work?

Alex Miller (Clojure team)13:07:55

can you put your full command line?

seancorfield17:07:06

@dominicm Yeah, I've only been able to get help/doc to work in very limited situations because :deps replaces your project dependencies.

seancorfield17:07:10

I'll write up a repro on ask...

Alex Miller (Clojure team)17:07:30

help/doc is really intended for tool use cases more than project use cases, but happy to consider things more fully

dominicm20:07:18

Nothing I saw solved for the project case. Here's my use-case: I have some functions in my project which I routinely want to run for doing things like installing generated data to the db, etc. These functions could be run from the REPL, but they're also good for the CLI too (with a little prn sprinkled in). I want the full set of project dependencies in there, not just a small subset I can specify using :extra-deps. https://ask.clojure.org/index.php/10888/help-doc-doesnt-work-with-project-dependencies and TDEPS-201 captures my wants well, and mentions solutions I think would work for me.

thanks3 2
seancorfield20:07:34

Yeah, the alternate root deps.edn alias version of :deps that does :extra-deps instead of :replace-deps seems like a good compromise. I have occasionally found myself wanting to just add t.d.a to something I'm doing so it would help with that too.

cldwalker16:07:48

Congrats on the official release! The project use case would be nice to have

seancorfield17:07:38

@alexmiller I had it working with a tool before but now I can't figure out what I had to do for that... can you remind me?

seancorfield17:07:44

Ah, I remembered!

clojure -A:deps -Tnew help/dir
That lists functions in the default namespace of the tool.

Alex Miller (Clojure team)17:07:15

yeah, you'll either want that or clojure -X:deps:whatever help/dir

seancorfield17:07:37

OK, so this works:

(! 766)-> cat deps.edn 
{:aliases {:csv {:extra-deps {org.clojure/data.csv {:mvn/version "RELEASE"}}}}}
(! 767)-> clojure -X:deps:csv help/doc :ns clojure.data.csv
Reading and writing comma separated values.
...
but without an alias, none of the project's basic :deps would work and that's "expected" because this is intended for "tools", not projects?

seancorfield17:07:46

I almost feel like there should be some "magic" alias that means "use the project :deps" 🙂

seancorfield17:07:42

I will raise an issue against clojure-site to add examples to the reference docs to show the two usages for tools...

seancorfield17:07:41

I suspect folks will wonder what -Tnew is so maybe my-tool instead?

seancorfield17:07:38

(although you could use -Tdeps-graph since that is actually used as an example on that page)

seancorfield17:07:13

This stuff is hard -- you never know what assumptions folks bring with them to a page of docs like that.

Alex Miller (Clojure team)17:07:21

I switched it to tools, which is built in

3
Alex Miller (Clojure team)17:07:51

also added a couple more notes and link to the api docs

mkvlr19:07:26

Congrats about the release, really excited about the new things. Ran into this after upgrading to Clojure CLI version 1.10.3.933 (artifact changed, we encountered this with a private dep):

clj -Srepro -Sdeps '{:deps {org.clojure/data.csv {:git/url "" :sha "aa9b3bdd3a1d3f6a7fe12eaab76b45ef3f197ad5" :tag "main"}}}'                ✘ 130 
Error building classpath. Library org.clojure/data.csv has invalid tag: main
Fixed by removing the :tag which previous versions would just ignore. Not sure if it should be considered a breaking change.

Alex Miller (Clojure team)19:07:08

yes, I'd consider that a bug and it kind of ties in with some issues we have with git-resolve-tags

Alex Miller (Clojure team)19:07:29

have you been using git-resolve-tags btw?

mkvlr20:07:09

not me personally (I’m used to manually looking up the sha on github and pasting it) but I think my colleague who added the dep is using it

Alex Miller (Clojure team)20:07:32

the new :git/tag expects only a valid tag (not a branch name like main)

Alex Miller (Clojure team)20:07:49

the old :tag with git-resolve-tags would happily resolve that

Alex Miller (Clojure team)20:07:13

so there are important differences here. I just tend to assume no one is using that stuff but clearly somebody is

seancorfield20:07:38

I have an example in my user deps.edn of using gitlibs/resolve for turning a branch name into a SHA: https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L177-L180 -- presumably @mkvlr could use that instead of git-resolve-tags?

mkvlr20:07:27

ah, and there’s no way to specify a branch and use tools.deps to update the sha from it anymore?

Alex Miller (Clojure team)20:07:49

at the moment, not really

mkvlr20:07:12

ok, not a big deal imo

mkvlr20:07:40

I guess being able to set a minimum CLI version would be nice, so we can upgrade to the newer :git/tag keys

mkvlr20:07:48

or is there currently anything I’m missing except asking everybody on the team to upgrade when relying on newer tools.deps features?

mkvlr20:07:42

(though of course the problem will only go away once everybody is on a version that supports requiring a minimum version, so not immediately helpful)

mkvlr20:07:33

another thought: could :git/ref be a thing to support in the future for mutable things like branches together with git-resolve-refs ? Also not sure if it would be nice to support :git/tag without needing a :sha. I feel like deleting or overwriting a released tag can be similar to force pushing a :sha out of the repo which can be gone once GC’d. But also see the upside of being explicit…

Joshua Suskalo20:07:18

These sorts of things I think goes against the idea of deps as data, since there's no reproducible way to run your project if it has a mutable dependency. Personally I'd favor having a -T tool which would update your dependencies in your deps edn based on a key like :git/ref , and then it just updates the sha in the dep with rewrite-clj

Joshua Suskalo20:07:47

Although it'd probably be like :tool-name.git/ref for the actual key

mkvlr20:07:18

@suskeyhose to be clear I was talking of a ref as a way to update a sha, so it would still be immutable. And tags I consider it to be best practice for them to not change (but can be forced to be overwritten) so I’m on the fence on that one.

Joshua Suskalo20:07:36

Then we were suggesting basically the same thing, but as a tool vs as a core part of tools deps I suspect

Joshua Suskalo20:07:06

Well, not quite if your suggestion was to validate that the ref does match that sha

dominicm20:07:18

Nothing I saw solved for the project case. Here's my use-case: I have some functions in my project which I routinely want to run for doing things like installing generated data to the db, etc. These functions could be run from the REPL, but they're also good for the CLI too (with a little prn sprinkled in). I want the full set of project dependencies in there, not just a small subset I can specify using :extra-deps. https://ask.clojure.org/index.php/10888/help-doc-doesnt-work-with-project-dependencies and TDEPS-201 captures my wants well, and mentions solutions I think would work for me.

thanks3 2
mkvlr20:07:49

we both want to update the sha, which git-resolve-tags used to do that (for both tags and branches, now only for tags). Think we all agree a tool is the way forward

👍 3
seancorfield20:07:38

I have an example in my user deps.edn of using gitlibs/resolve for turning a branch name into a SHA: https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L177-L180 -- presumably @mkvlr could use that instead of git-resolve-tags?

mkvlr20:07:55

yeah, though I’m not sure I’m ever going to change my habit of just copy & pasting the sha from GitHub, comes with the upside of seeing the commit etc 🙈

borkdude21:07:44

Now that that deps.edn has some new rules, the linting for it in clj-kondo needs to be updated. Please test your deps.edns and report any false positives, please!

$ clojure -Sdeps '{:deps {clj-kondo/clj-kondo {:git/url "" :sha "05cc5aca58d89215a295799df8e27fa1a9874885"}}}' -M -m clj-kondo.main --lint deps.edn
Checking out:  at 05cc5aca58d89215a295799df8e27fa1a9874885
linting took 52ms, errors: 0, warnings: 0
You can report false positives in this issue: https://github.com/clj-kondo/clj-kondo/issues/1318 🙏

borkdude21:07:10

(especially when you're using the new features)