gpt4 book ai didi

emacs - clojure.tools.namespace refresh-all 后 clojure.repl 命名空间丢失

转载 作者:行者123 更新时间:2023-12-01 11:33:26 25 4
gpt4 key购买 nike

我不确定这是预期的还是错误,但在运行后 (clojure.tools.namespace.repl/refresh-all) clojure.repl命名空间丢失。

nREPL server started on port 61579 on host 127.0.0.1 nrepl://127.0.0.1:61579
REPL-y 0.3.5, nREPL 0.2.7
Clojure 1.6.0

testbed.core=> (doc map)
-------------------------
clojure.core/map
([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])
Returns a lazy...
nil
testbed.core=> (require 'clojure.tools.namespace.repl)
nil
testbed.core=> (clojure.tools.namespace.repl/refresh-all)
:reloading (testbed.core testbed.core-test)
:ok
testbed.core=> (doc map)

CompilerException java.lang.RuntimeException: Unable to resolve symbol: doc in this context, compiling:(/private/var/folders/xs/jbvb_r6j07q8xtclwlcbm21h0000gn/T/form-init6764593924445976503.clj:1:1)
testbed.core=>

我的 project.clj 非常简单:

(defproject testbed "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:main ^:skip-aot testbed.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}
:dev {:dependencies [[org.clojure/tools.namespace "0.2.10"]]}})

有没有简单的方法可以避免这种情况?特别是在运行 Emacs/CIDER 时?

最佳答案

我记得有这个问题。虽然已经有一段时间了,但我记得通过设置我的 lein 项目来启动命名空间 user 中的 repl 来解决这个问题。并导入其他命名空间 - 而不是从项目命名空间(由 :main 定义)开始。

所以我加了:repl-options {:init-ns user}到我的 project.clj并创建了一个项目 user.clj - 确保 clojure.repl我需要的功能始终可用 - 如 Stuart Sierra 的帖子 "My Clojure Workflow, Reloaded" 中所述

session :

user=> (doc +)
-------------------------
clojure.core/+
([] [x] [x y] [x y & more])
Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'
nil

user=> (clojure.tools.namespace.repl/refresh-all)
(...namespaces...)

user=> (doc +)
-------------------------
clojure.core/+
([] [x] [x y] [x y & more])
Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'
nil

这是一种变通方法,而不是对行为的真正修复或解释。另一种方法是确保

关于emacs - clojure.tools.namespace refresh-all 后 clojure.repl 命名空间丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29991666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com