tools-deps

Discuss tools.deps.alpha, tools.build, and the clj/clojure command-line scripts! See also #depstar #clj-new
Eugen 2020-12-23T07:17:15.055900Z

thanks, I'll see what I can do then. My goal, as I said is to be able to use my version of clj-antl (with patches) from git. deps.edn seemed like a good fit until I got to the java classes for which I don't have a solutin. I do have a direction now. Let's see where it leads.

2020-12-23T19:17:40.061200Z

Hi all, I'm learning about clj and deps.edn, and I had come up with an alias to connect to an nrepl server:

:dev {;; some dev deps }  
:repl/connect {:extra-paths ["env/dev" "resources/dev]
                 :extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}}  
                 :main-opts ["-m" "nrepl.cmdline" "--connect"]}}}  
This allowed me to run clj -M:dev:repl/connect --host $HOST --port $PORT Then I was reading about .clojure/deps.edn and figured I could move that repl/connect alias out, and I ended up with these snippets:
;; .clojure/deps.edn
  :repl/connect {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}}
                 :main-opts ["-m" "nrepl.cmdline" "--connect"]}}}

;; repository
  :repl/connect {:extra-paths ["env/dev" "resources/dev"]}
I thought this would basically merge these into the first form, but not when I run clj -M:dev:repl/connect --host $HOST --port $PORT I see
Exception in thread "main" java.io.FileNotFoundException: --host (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
        at clojure.lang.Compiler.loadFile(Compiler.java:7570)
        at clojure.main$load_script.invokeStatic(main.clj:452)
        at clojure.main$script_opt.invokeStatic(main.clj:512)
        at clojure.main$script_opt.invoke(main.clj:507)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)
It seems like I'm missing something but I don't know what. I'd like a generic repl/connect that I can use across projects and pass --host and --port to

seancorfield 2020-12-23T19:45:25.062900Z

Aliases overwrite each other in the system -> user -> project -> command-line order (so last one wins).

dorab 2020-12-23T19:45:43.063300Z

If I understand correctly, merge takes the last value of the key. So, since you are using the same key in your ~/.clojure/deps.edn and in your ${REPODIR}/deps.edn the one in the repo is "winning" and overriding the other one. It is probably best to use two different aliases and add them to the -M: command line option.

đź‘Ť 1
seancorfield 2020-12-23T19:45:47.063600Z

The merge happens on the :aliases key, not on the nested aliases themselves.

seancorfield 2020-12-23T19:46:42.064700Z

So, in your case, :repl/connect in your project overwrites your user-level version and thus the --host argument is passed to Clojure's main, because the nREPL stuff isn't present in the merged EDN.

seancorfield 2020-12-23T19:47:39.065700Z

If you have multiple non-conflicting aliases, the bodies of the aliases are merged, but with :main-opts the last one wins (those are not merged). /cc @dorab

dorab 2020-12-23T19:49:44.065800Z

@seancorfield’s response in the main thread is more accurate than mine.

Derek Passen 2020-12-23T19:55:45.066700Z

It also looks like your repository’s :repl/connect alias’ :extra-paths may be more suited to be in :dev?

2020-12-23T20:00:55.067300Z

@seancorfield oh I see, I thought the merging happened on the aliases themselves. Thanks!

2020-12-23T20:01:24.067500Z

thank you, I thought it merged the aliases themselves