Fork me on GitHub
#tools-deps
<
2021-01-26
>
CarnunMP12:01:08

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.

borkdude12:01:12

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

👀 3
3
CarnunMP12:01:11

I think that's done it. Cheers!

dpsutton13:01:12

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?

Alex Miller (Clojure team)13:01:18

The -A are always pulled in last

Alex Miller (Clojure team)13:01:47

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

dpsutton13:01:33

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

dpsutton13:01:25

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

Alex Miller (Clojure team)13:01:10

I do not think that is a good template - all of the aliases should be under -M imo

dpsutton13:01:02

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

dpsutton13:01:40

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?

dpsutton13:01:27

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

dpsutton13:01:48

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?

Alex Miller (Clojure team)13:01:44

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

Alex Miller (Clojure team)13:01:10

does :cider/nrepl have :main-opts?

Alex Miller (Clojure team)13:01:16

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

Alex Miller (Clojure team)13:01:45

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

dpsutton14:01:11

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.

dpsutton14:01:01

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.

Alex Miller (Clojure team)14:01:25

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).

dpsutton14:01:03

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

Alex Miller (Clojure team)14:01:35

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

dpsutton14:01:14

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 🙂

tvaughan14:01:35

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

Alex Miller (Clojure team)14:01:04

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

Alex Miller (Clojure team)14:01:42

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

dominicm15:01:56

I think that's intentional, it's reading the literally written deps in order to make decisions based on those. It's not trying to resolve the location of those deps nor include system or user deps.

Alex Miller (Clojure team)15:01:52

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

dominicm15:01:27

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.

lread18:01:47

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

uochan22:01:01

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

tvaughan14:01:31

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

dominicm15:01:56

I think that's intentional, it's reading the literally written deps in order to make decisions based on those. It's not trying to resolve the location of those deps nor include system or user deps.