sup! quick question: how to define functions on :injections
? My ~/.lein/profiles.clj looks like this, but add-dependency
is never available in my repl (`hashp.core` is loaded correctly, which is stranger for me)
{:user {:plugins [[lein-pprint "1.1.2"]
[com.jakemccrary/lein-test-refresh "0.23.0"]
[com.cemerick/pomegranate "0.4.0"]]
:dependencies [[fipp "0.6.14"]
[hashp "0.1.1"]
[com.cemerick/pomegranate "0.4.0"]]
:injections [(do
(require 'hashp.core)
(defn add-dependency [dep-vec]
(require 'cemerick.pomegranate)
((resolve 'cemerick.pomegranate/add-dependencies)
:coordinates [dep-vec]
:repositories (merge @(resolve 'cemerick.pomegranate.aether/maven-central)
{"clojars" "<https://clojars.org/repo>"}))))]
:test-refresh {:notify-command ["notify-send" "-t" "1000"]
:quiet true
:changes-only true}}}
(I also tried without wrapping it with do
the injections don't neccessarily happen in your init-ns do they?
my suspicion is that those requires happen in some other ns, before your ns is loaded, you use hashp.core
by its full name, so it just works
that's what I thought too, but the docs say: > Forms to prepend to every form that is evaluated inside your project.
that doesn't imply they ever run inside your ns
with a prepend, (require 'my-ns) (in-ns 'my.ns)
turns into (custom form) (require 'my.ns) (in-ns 'my.ns)
- I wouldn't expect a prepend to end up running code in your init-ns unless you explicitly make it do so
but that'd be just the first form in the ns. I'd expect it to prepend it to every form
but yeah, makes sense for it to be some quirky behavior related to that
every form that is evaluated inside your project
isn't your repl, it's literally the forms in the project.clj file
ahhhh. ok
@caio I bet what you want is :repl-options {:init ...}
- that code will run in your startup ns, when a new repl connection is made
and the lein docs make clear it is run in your startup ns
damn, right on. thanks a lot
np