Fork me on GitHub
#tools-deps
<
2020-12-23
>
Eugen07:12:15

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.

tomgeorge19:12:40

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

dorab19:12:43

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.

đź‘Ť 3
dorab19:12:44

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

tomgeorge20:12:24

thank you, I thought it merged the aliases themselves

seancorfield19:12:25

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

seancorfield19:12:47

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

seancorfield19:12:42

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.

seancorfield19:12:39

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

Derek19:12:45

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

tomgeorge20:12:55

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