lein repl在错误的命名空间中启动 [英] lein repl starts in wrong namespace

查看:263
本文介绍了lein repl在错误的命名空间中启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TLDR;



lein repl 根据需要替换用户中的:main



我有一个 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以此优先顺序切换:


  1. :init-ns of:repl-options

  2. ns


  3. 在您的情况下,尝试添加:

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

    1. ns specified in the :init-ns of the :repl-options
    2. ns specified :main
    3. user ns

    In your case, try adding:

    :repl-options {:init-ns user}
    

    to your project.clj

    这篇关于lein repl在错误的命名空间中启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆