leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
2020-02-10T18:45:21.091600Z

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}}} 

2020-02-10T18:50:42.091900Z

(I also tried without wrapping it with do

2020-02-10T19:15:36.092300Z

the injections don't neccessarily happen in your init-ns do they?

2020-02-10T19:17:27.093700Z

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

2020-02-10T19:22:26.094200Z

that's what I thought too, but the docs say: > Forms to prepend to every form that is evaluated inside your project.

2020-02-10T20:18:44.094700Z

that doesn't imply they ever run inside your ns

2020-02-10T20:20:41.096400Z

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

2020-02-10T20:24:42.097500Z

but that'd be just the first form in the ns. I'd expect it to prepend it to every form

2020-02-10T20:24:55.097800Z

but yeah, makes sense for it to be some quirky behavior related to that

2020-02-10T20:25:48.098300Z

every form that is evaluated inside your project isn't your repl, it's literally the forms in the project.clj file

2020-02-10T20:26:18.098500Z

ahhhh. ok

2020-02-10T20:29:08.099700Z

@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

2020-02-10T20:29:34.100100Z

and the lein docs make clear it is run in your startup ns

2020-02-10T20:30:18.100700Z

damn, right on. thanks a lot

2020-02-10T20:30:23.100900Z

np