This question is a follow up to How does one pre-load a clojure file in the leiningen repl?.
My ~/.lein/profiles.clj
looks as follows:
{
:user {:source-paths ["C:/Users/username/.lein/src"] }
}
My ~/.lein/src/user.clj
might look as follows:
(ns user)
(println "user file loaded")
When I run lein repl
within a folder containing a project.clj
, then the user.clj
file is executed, but when I run lein repl
from another folder it doesn't load my user profile. Is there a workaround for this or is this behavior by design? In fact, I know that Leinigen is indeed loading my profile.clj
(even when there is no project.clj) because there are also other things inside (taken from the excellent pimp my repl article). Leinigen is just having problems with my additional source-paths setting.
One other question related to this is the fact that I need to specify the full path of the folder for my user.clj
file : "C:/Users/username/.lein/src"
. When I change that to "~/.lein/src"
leiningen fails to load my file.
It sounds like you just want some code loaded for your lein repl
sessions. This is done with the :init
key of the :repl-options
in your profiles.clj
. You can load-file
other files in init
if you want to organize in that fashion.
{:user
{:repl-options
{:init (load-file "path-to-file/user.clj")}
...}}
Note: If you are using Windows-style path delimiters /
, you'll need to escape them //
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With