Support access via deps.edn git coordinate
spencerwilson opened this issue · 5 comments
Hello, Thanks for your work on cljfmt!
Problem
I'm eager to get the changes in #274 but they're not released yet, so I changed tack and attempted a change like the following in my project:
- :extra-deps {cljfmt/cljfmt {:mvn/version "0.9.0"}}}
+ :extra-deps {io.github.weavejester/cljfmt {:deps/root "cljfmt" :git/sha "cf708becf6e202ef0bc8c635aebbc49be7cd1c61"}}}
That didn't work though, since tools.deps doesn't support as dependencies packages that use Leiningen's "project.clj" as their manifest: https://github.com/clojure/tools.deps/blob/6ae2b6f71773de7549d7f22759e8b09fec27f0d9/src/main/clojure/clojure/tools/deps/extensions.clj#L21
As a result, the Clojure CLI tools don't know how to resolve the above dependency:
% clj -M:cljfmt --help
Error building classpath. Manifest file not found for io.github.weavejester/cljfmt in coordinate {:deps/root "cljfmt", :git/sha "cf708becf6e202ef0bc8c635aebbc49be7cd1c61", :git/url "https://github.com/weavejester/cljfmt.git"}
Suggested solution
Maybe have both a project.clj and deps.edn? The former would remain authoritative for development on cljfmt, whereas the latter would be for the benefit of teaching tools.deps what it needs to know to load the source tree as a dependency. This approach risks drift between the two manifests, and would increase maintenance burden.
Ah, @seancorfield suggested a workaround here: https://ask.clojure.org/index.php/8507/failure-on-github-import-via-deps
Workaround didn't actually suffice: readresource
macroexpansion here e.g.,
cljfmt/cljfmt/src/cljfmt/core.cljc
Line 292 in 9de4fab
would fail due to the indents resources not being on the classpath. I'm not sure if it's tools.deps who, when processing a git dependency, isn't putting the resources on the classpath that it sets up, or what. Am somewhat out of my depth here and had to move on.
Fixed by #293.
Indeed:
bb -Sdeps '{:deps {cljfmt/cljfmt {:git/url "https://github.com/weavejester/cljfmt" :git/sha "7dfd55d5dd0756f30311a90f206c2dd32e56d18b" :deps/root "cljfmt"}}}' -m cljfmt.main
works fine now.
Thanks a lot for all the effort in improving this! 🐰 👍
Note: at this moment there is not a new release-tag, the current one is 0.9.2
, so the only way to use this in deps.edn
is with a commit (full sha) after #293 was merged:
:cljfmt-check {:extra-deps {io.github.weavejester/cljfmt {:git/sha "3418b7f4c82c2a5acebc3c41e50138ea80d17010" :deps/root "cljfmt"}}
:main-opts ["-m" "cljfmt.main" "check"]}
Having just the commit does not help to get the idea of what version one is using 🙃