lein repl在错误的命名空间中启动 [英] lein repl starts in wrong namespace
问题描述
TLDR;
lein repl
根据需要替换用户
在中的
我有一个 Leiningen 项目,它作为一个命令行应用程序部署在uberjar中,所以我可以这样运行:
java -jar my-app-1.0-standalone.jar --some --args
我也有一个 dev / user.clj
给我一个不错的REPL环境,如此处描述。
我的 project.clj
看起来像这样:
(defproject my-app1.0
:main my-app.cli
:aot [my-app.cli]
:profiles {:dev {:source-paths [srcdev]}} )
当我开始我的REPL时,使用 lein repl
从命令行或 Mx cider-jack-in
从Emacs,我在 my-app.cli
命名空间,而不是 user
。
如果我删除:main my-app我的REPL在
用户
命名空间中以I'开头
<
当lein repl任务运行时,它将查找ns以此优先顺序切换:
- :init-ns of:repl-options
- ns :
- ns specified in the :init-ns of the :repl-options
- ns specified :main
- user ns
在您的情况下,尝试添加:
:repl-options {:init- ns user}
到您的project.clj
TLDR;
lein repl
starts in the namespace defined by :main
in project.clj
, instead of user
, as desired.
Details
I have a Leiningen project which is deployed as a command-line application in an uberjar, so I can run it like so:
java -jar my-app-1.0-standalone.jar --some --args
I also have a dev/user.clj
to give me a nice REPL environment, as 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 start my REPL, either with lein repl
from the command line or M-x cider-jack-in
from Emacs, I am in the my-app.cli
namespace, rather than user
.
If I remove :main my-app.cli
from project.clj
, my REPL starts in the user
namespace as I'd expect, but clearly this breaks my uberjar.
Any ideas?
When lein repl task runs, it will look up the ns to switch to in this order of preference:
In your case, try adding:
:repl-options {:init-ns user}
to your project.clj
这篇关于lein repl在错误的命名空间中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!