User.clj and init.clj not working?

This is my problem: I need to run some code every time I open a new replica and search on Google, I found that I can use the init.clj or user.clj (with Leiningen)

This is the code I need to run:

 (set! *print-length* 103) (println "hello") (println *print-length*) 

These are the results with both files:

 [~/project]$ lein repl hello <- this is the println, so the file is excecuted 103 <- this is the println of *print-length* apparently change REPL started; server listening on localhost port 20875 user=> *print-length* nil <- but the val of *print-length* don't change 

Is there something I need to do or do I have some error?

Thanks everyone!

+7
source share
2 answers

(alter-var-root #'*print-length* (constantly 103)) in ~/user.clj works for me.

As far as I know, set! does not work outside the dynamic binding .

+4
source

lein init.clj runs in the leiningen process, not in your project process. See https://github.com/technomancy/leiningen (search for init.clj)

+4
source

All Articles