Fork me on GitHub
#tools-deps
<
2023-01-29
>
dominicm20:01:16

Something that slightly surprises me: extra-paths specified in ~/.clojure/deps.edn aren't relative to ~/.clojure/deps.edn but the CWD. I suppose that's because it's directly merged rather than considered as its own source? I'm interested in doing this so that I can load a .clj file from ~/.clojure/... which loads a few common dev helpers for all projects I might work on (e.g. https://github.com/gfredericks/dot-slash-2)

dominicm20:01:50

Here's what I tried:

{:aliases
 {:user/dev
  {:extra-deps {com.gfredericks/dot-slash-2 {:mvn/version "0.1.5"}
		vvvvalvalval/scope-capture {:mvn/version "0.3.3"}}
   :jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
   :extra-paths ["mydev"]
   :main-opts ["-i" "@mydev.clj"]}}}

Alex Miller (Clojure team)20:01:13

:paths and :extra-paths are relative to the location of the project deps.edn, and yes, all deps sources are merged prior to resolution

Alex Miller (Clojure team)20:01:52

you could instead use an alias that had :extra-deps to a local project root

dominicm20:01:36

That local root is still relative to the project deps.edn in my tests

Alex Miller (Clojure team)20:01:43

it is, but could also be absolute to anywhere

Alex Miller (Clojure team)20:01:01

there is no provided mechanism for making paths relative to the config directory

Alex Miller (Clojure team)20:01:13

(and I don't expect to add one)

Alex Miller (Clojure team)20:01:49

another approach is to put it in a git repo

☝️ 2
skylize22:01:53

Use the absolute path?

dominicm22:01:49

That's a shame. I don't want to use an absolute path so the same thing works on all of the machines I work from.

skylize23:01:59

I was going to test if there might be a solution around the`$XDG_CONFIG_DIR` variable. But it looks like even a plain absolute path is not going to work for you.

{:aliases
 {:path-test {:extra-paths ["/home/sky/.config/clojure/src"]}}}
$ clj -M:path-test
WARNING: Use of :paths external to the project has been deprecated, please remove: /home/sky/.config/clojure/src
Clojure 1.11.1
user=> 

dominicm00:01:28

https://www.git-scm.com/docs/gitattributes Filter and smudge might be the way to go