Fork me on GitHub
#tools-deps
<
2021-08-02
>
seancorfield00:08:43

Just in case anyone wants to know how to run tests using build.clj (instead of clojure -M:test or clojure -X:test as a separate step), I have added an example to next.jdbc's repo, since it uses a barebones invocation of the Cognitect test-runner: https://github.com/seancorfield/next-jdbc so you do clojure -T:build run-tests

seancorfield00:08:51

(this is only really useful if you want a build command that runs your tests as part of a bunch of other stuff -- otherwise you're just spinning up a subprocess for no good reason)

💯 7
seancorfield00:08:31

Note: this is not a -X-style invocation of test-runner (even though clojure -X:test is how I normally run tests in that project)!

markaddleman02:08:56

I'm getting this error when my deps.edn includes `

techascent/tech.ml  {:mvn/version "6.001"}
I've tried deleting my entire .m2/repository directory but the error reoccurs. Any idea what's going on?

seancorfield02:08:28

@markaddleman try adding -Sthreads 1 to your CLI invocation.

seancorfield02:08:51

FWIW, clojure -Sdeps '{:deps {techascent/tech.ml {:mvn/version "6.001"}}}' works fine for me so there's no inherent problem with that lib.

markaddleman02:08:15

Thanks. I'm getting a new error now:

Error building classpath. Could not transfer artifact args4j:args4j:jar:2.0.26 from/to central (): status code: 416, reason phrase: Range Not Satisfiable (416)
I think I've made progress

markaddleman02:08:22

I'm also on very spotty wi-fi so I

markaddleman02:08:29

So I'll try again when I get home

seancorfield02:08:39

Ah, spotty wifi. Yeah, definitely -Sthreads 1. And you may need to delete your ~/.m2/repository and start fresh to avoid corrupted files.

markaddleman02:08:26

-Sthreads 1 did the trick. Thanks!

Jeff Evans14:08:24

is it possible to specify BOM dependencies via deps.edn ? ex:

seancorfield17:08:58

@jeffrey.wayne.evans No, not currently. You have to specify all the components of the BOM explicitly instead. I suspect this would get a lot of upvotes if it was posted on http://ask.clojure.org

👍 4
dpsutton19:08:15

Suppose you have a few aliases "alias1, alias2, etc" and a main entry point "foo", how would you invoke this? I would think clojure -A:alias1:alias2 -M foo ? Or do you just clojure -M:alias1:alias2:foo? Is there a difference, or one to be preferred over another?

dpsutton19:08:31

(foo here is an alias that specifies :main-opts

seancorfield19:08:42

I would use the second format.

dpsutton19:08:39

do you have a reason for that? just preference, unambiguous merging of main opts, etc?

seancorfield19:08:38

I pretty much only use -A now if I'm starting a REPL or have a very specific use case where -A is the right approach, e.g., clojure -A:deps -Tnew help/doc

dpsutton19:08:30

I see. This is for a coworker that needs an nrepl main so it kinda feels the same as that to me: clojure -A:dev -M:nrepl kinda feels the same

seancorfield19:08:36

I've always used just one flag and a concatenated list of aliases...

seancorfield19:08:38

I think it's just personal preference. I find a single flag option "clearer" in that you immediately see "I run a -main" or "I run exec function" (or "I start a REPL") -- -M or -X (or -A).

dpsutton19:08:31

yeah. i guess i like the other version for precisely that reason clojure -A:classpath-additions -M entrypoint

dpsutton19:08:40

ok. well as long as its not wrong 🙂

seancorfield20:08:57

The docs seem to encourage my style:

clojure [clj-opt*] -X[aliases] [a/fn] [kpath v]* kv-map?
clojure [clj-opt*] -M[aliases] [main-opts]

dpsutton20:08:48

that's a good point. I guess i was thinking of when the changeover happens such that -A will no longer allow main options to "win".

dpsutton20:08:08

but i think you've convinced me now that it is wrong, but perhaps happens to work

seancorfield20:08:34

Also, where it describes how various options (in deps.edn) are provided, it says "should be provided as an alias in one of the deps sources and provided to the Clojure tools using -A (for REPL invocation), -X (for function execution), or -M (for clojure.main execution)." which reads to me as "you use either -A or -X or -M" (even though you can provide -A and either -X or -M).

👍 2
dominicm21:08:39

@dpsutton RE tooling, I'm not sure what cider's opts are atm, but I have been thinking about switching my setup over to taking a list of aliases which are passed to -A as you can't combine -M or -X with the nrepl start code anyway. The downside to that is how main-opts concatenate, so I can have an alias containing :main-opts ["-i", "init.clj"] to inject some startup code, but I suppose -M:user:provided:aliases is just as valid so it's probably OK.

dpsutton21:08:07

cider used to use just trailing main args with -M -m nrepl/cmdline host port but if there were any profiles in the provided aliases those would actually dominate. so now it uses inline -Sdeps {:cider/nrepl {:main-args ..}} and then adds the profile cider/nrepl as the last profile so it wins under any strategy