tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
Carnun 2021-01-26T12:03:08.045500Z

Hi all. Quick question - I hope this is the right place to ask it! :)) Lets say I have a user namespace in the same directory as my deps.edn, containing a start function. Why is this ⬇️ happening?

Clojure 1.10.1
user=> (start)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: start in this context
user=> (require 'user)
Execution error (FileNotFoundException) at user/eval2 (REPL:1).
Could not locate user__init.class, user.clj or user.cljc on classpath.

borkdude 2021-01-26T12:05:12.046Z

@carnunmp you should probably put the user.clj on your classpath, e.g. in src ?

👀 1
1
Carnun 2021-01-26T12:11:11.046300Z

I think that's done it. Cheers!

dpsutton 2021-01-26T13:09:12.050200Z

I'm trying to ensure that the {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[\"cider.nrepl/cider-middleware\"]"]} main opts for cider startup are run in case there are main opts in the aliases used. The documentation states that "If multiple maps with these keys are activated, only the last one will be used". My attempt to make nrepl.cmdline the "last" is the following: /usr/local/bin/clojure -A:test -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.7"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[\"cider.nrepl/cider-middleware\"]"]}}}' -M:cider/nrepl (where -A:test includes a main runner for kaocha). My assumption was that putting -M:cider/nrepl last in the string would ensure that it was last for the purposes of main arg combining but this doesn't seem to work. It still starts the kaocha runner instead of the nrepl server. Is there a way to achieve this? Have I misunderstood what last is in how the aliases are combined?

alexmiller 2021-01-26T13:16:18.051300Z

The -A are always pulled in last

alexmiller 2021-01-26T13:16:47.052100Z

Is there some reason you’re not doing both aliases in -M

alexmiller 2021-01-26T13:17:31.052900Z

-M:cider/nrepl:test

dpsutton 2021-01-26T13:22:33.053400Z

yes. this is CIDER's startup command which the user can add their own aliases to like a template

dpsutton 2021-01-26T13:23:25.054300Z

the template being clojure [optional user aliases] -Sdeps {...} -M:cider/nrepl but it seems this is not a good template?

dpsutton 2021-01-26T13:24:02.055Z

i suppose clojure -Sdeps {...} -M:[optional user aliases]:cider/nrepl is a way to ensure cider/nrepl is the last alias?

dpsutton 2021-01-26T13:26:40.055800Z

and if so, are there any implications to tucking what someone thought would run under -A:foo instead under -M:foo:cider/nrepl besides the desired suppression of the possible main opts?

dpsutton 2021-01-26T13:30:27.056300Z

or perhaps we could look for -A and replace with -R? (R is gone it seems)

dpsutton 2021-01-26T13:33:48.057400Z

reading clj --help

exec-opts:
 -Aaliases      Use concatenated aliases to modify classpath
 -X[aliases]    Use concatenated aliases to modify classpath or supply exec fn/args
 -M[aliases]    Use concatenated aliases to modify classpath or supply main opts
 -P             Prepare deps - download libs, cache classpath, but don't exec
it seems perhaps the current invocation will be correct under a future version? Reading -A and -M to differ by the -M allowing for main opts and therefore -A to not propagate those keys?

alexmiller 2021-01-26T13:56:44.058400Z

-A does currently provide :main-opts, but long-term, it will not

alexmiller 2021-01-26T13:57:10.058700Z

does :cider/nrepl have :main-opts?

alexmiller 2021-01-26T13:57:53.059Z

I guess so

alexmiller 2021-01-26T13:58:16.059400Z

going back to your original question, why are you trying to use both cider and run test?

alexmiller 2021-01-26T13:58:45.059800Z

seems like you should be doing one or the other but not both

dpsutton 2021-01-26T14:03:11.061900Z

yes :cider/nrepl specifies the {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[\"cider.nrepl/cider-middleware\"]"]} so that the nrepl server is correctly started up for CIDER. This bug came up because someone had an alias which included kaocha, its main runner as main-opts, and extra test paths. Kaocha does have a useful repl mode, and the test paths are desirable as well. So it was hoped that the alias could be used and the main ignored in favor of CIDER's requirements.

dpsutton 2021-01-26T14:04:01.062800Z

So the hope was to structure the startup command in a way that we naturally eclipsed all other main args in favor of our own.

dpsutton 2021-01-26T14:05:14.063700Z

i've already made the change for the template string to be -M[optional-args]:cider/nrepl so thanks for your help. Its always appreciated and the clojure cli as well 🙂

tvaughan 2021-01-26T14:17:35.065Z

Sorry, I'm not sure which is the best channel to ask this (I don't see an antq channel), but is anyone using antq to keep dependencies from a password protected maven repo up-to-date in deps.edn? Everything is setup correctly and works with tools.deps. Only antq seems to have a problem. For example, with Datomic dev-local:

|    :file |                 :name | :version | :latest-version |
|----------+-----------------------+----------+-----------------|
| deps.edn | com.datomic/dev-local |  0.9.225 | Failed to fetch |
|  pom.xml | com.datomic/dev-local |  0.9.225 | Failed to fetch |
Searching the antq github repo didn't turn up any relevant issues, nor do I see a verbose or debug option to get additional details

alexmiller 2021-01-26T14:20:25.065800Z

ah, ok. so the intent was to NOT get kaocha main when starting cider main (I was thinking it was the opposite). Indeed, once -A changes to not support :main-opts, what you had would have worked (but does not currently).

alexmiller 2021-01-26T14:21:19.066100Z

link for antq?

borkdude 2021-01-26T14:21:27.066300Z

https://github.com/liquidz/antq

dpsutton 2021-01-26T14:22:03.066700Z

correct. sorry i was unclear in desired behavior. I've made the change with the note that we can go back at some point in the future. thanks for helping confirm i'm doing things the right way. much appreciated

alexmiller 2021-01-26T14:24:04.067200Z

seems like a bug in antq so I'd file an issue there

alexmiller 2021-01-26T14:24:42.067900Z

weirdly antq is using tools.deps.alpha for parts of its maven code, but not using it to read deps from deps.edn files

tvaughan 2021-01-26T14:25:31.068600Z

Great! Thank you @alexmiller I'll file a bug

alexmiller 2021-01-26T14:26:35.068700Z

well I was still half asleep when I first read it so prob me :)

tvaughan 2021-01-26T14:40:21.069Z

https://github.com/liquidz/antq/issues/54

alexmiller 2021-01-26T15:34:52.069600Z

I get that, but even so it could be using more of tools.deps

dominicm 2021-01-26T15:35:27.069800Z

I haven't checked the source, but there might also be a desire to use tools.reader to modify the deps.edn without losing comments and such. Not sure.

lread 2021-01-26T18:33:47.070Z

Just in case @liquidz.uo (the author of antq) is not browsing, this convo, I’ve roped them in!

2021-01-26T22:09:01.070500Z

Oh, thanks for your information! I should read tools.deps source more and more.