Lein repl starts in the wrong namespace

TL; DR;

lein repl starts in the namespace defined by :main in project.clj , instead of user , if required.

More details

I have a Leiningen project that deploys as a command line application in uberjar, so I can run it like this:

 java -jar my-app-1.0-standalone.jar --some --args 

I also have dev/user.clj to give me a nice REPL environment, described here .

My project.clj looks like this:

 (defproject my-app "1.0" :main my-app.cli :aot [my-app.cli] :profiles {:dev {:source-paths ["src" "dev"]}}) 

When I run my REPL, either with lein repl from the command line or Mx cider-jack-in from Emacs, I am in the my-app.cli , not user .

If I remove :main my-app.cli from project.clj , my REPL runs in the user namespace as I expected, but this clearly violates my uberjar.

Any ideas?

+6
source share
1 answer

When the lein replacement task is executed, it will look for ns to switch in this order of preference:

  • ns specified in: init-ns: repl-options
  • ns indicated: main
  • user ns

In your case, try adding:

 :repl-options {:init-ns user} 

to your .clj project

+4
source

Source: https://habr.com/ru/post/972137/


All Articles