Fork me on GitHub
#tools-deps
<
2022-03-11
>
mruzekw17:03:18

Hey there, I'm trying to output a string of edn to stdout via clj -T... and for some reason I can't get the namespace to load. I feel like there's something simple I'm missing. Can anyone spot it? deps.edn aliases

:aliases {:jib-config {:replace-paths ["dev/tools"]
                       :exec-fn tools.skaffold/get-skaff-config}}
<project-root>/dev/tools/skaffold.clj
(ns tools.skaffold)

(defn get-skaff-config [_]
  (with-out-str (clojure.pprint/pprint {:x 1 :y -1})))
Output
❯ clj -T:jib-config
Namespace could not be loaded: tools.skaffold

mruzekw17:03:20

-X yields the same results

❯ clj -X:jib-config
Namespace could not be loaded: tools.skaffold

Alex Miller (Clojure team)17:03:16

you want :replace-paths ["dev"]

Alex Miller (Clojure team)17:03:42

the namespace (tools.skaffold) is relative to the path (dev) - those get put together

mruzekw17:03:16

So paths can only be root folders?

mruzekw17:03:13

I also have dev/user.clj which takes sometime to load and has some extra stdout, which is why I was trying to avoid it.

Alex Miller (Clojure team)17:03:35

yes, that's how the JVM classpath works

Alex Miller (Clojure team)17:03:59

you could put one of these things under another root of course

mruzekw17:03:02

Gotcha, thanks. Yeah still pretty new to the JVM

Alex Miller (Clojure team)17:03:36

namespace is munged into a resource path, then that resource path is checked relative to each classpath location

Alex Miller (Clojure team)17:03:53

tools.skaffold => tools/skaffold.clj => look for that in dev/ (and other locations)

mruzekw17:03:43

Gotcha, thanks, makes sense