2017-05-29 48 views
2

我正在使用tools.namespace来为REPL上的名称空间提供智能重新加载。但是,当致电refreshrefresh-all时,会引发错误。clojure.tools /名称空间刷新失败,并显示“No namespace:foo”

user=> (require '[clojure.tools.namespace.repl :as tn]) 
user=> (tn/refresh) 
:reloading (ep31.common ep31.routes ep31.config ep31.application user ep31.common-test ep31.example-test) 
:error-while-loading user 

java.lang.Exception: No namespace: ep31.config, compiling:(user.clj:1:1) 

而且似乎在(require ep31.config)作品没有错误,但事后命名空间不能实际上说明这个奇怪的状态结束。

回答

4

我有点想通了这一点,这似乎是的情况下留在target/classes

  • 有AOT编译的类从做lein uberjar组合以前
  • tools.namespace不正常加载时命名空间AOT编译
  • target/classes默认情况下在classpath

那么长的故事小号hort,如果你之前构建了jar/uberjar,那么删除target/并且事情应该重新开始。

我还没有能够解决的问题是为什么target/classes是在类路径上开始。我怀疑它正在被Leiningen添加,但还没有发现它在哪里或为什么发生。

+0

这是正确的。 Leiningen默认将'target/classes'放在类路径上,原因有两个:1)为已编译的Java源提供应用程序,2)AOT编译的输出目录('* compile-path *')必须为on类路径。 –

+1

因此,如果你在做'lein uberjar'之后做了'lein clean',你不会遇到你的问题吗?或者,只要你进入一个糟糕的状态,就像你在问题中所描述的那样,“干净”。 –

-1

我这学到了艰辛的道路,为:target-path文件说,(https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L309-L313):

;; All generated files will be placed in :target-path. In order to avoid 
;; cross-profile contamination (for instance, uberjar classes interfering 
;; with development), it's recommended to include %s in in your custom 
;; :target-path, which will splice in names of the currently active profiles. 
:target-path "target/%s/" 

我想必须有遗留原因,:target-path "target/%s/"不是默认。

+0

尽管这个链接可能回答这个问题,但最好在这里包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/18777954) –

+1

好点!包括':target-path'的文档,现在答案应该更有意义(文档在描述问题时非常简洁)。 – Viesti

相关问题