在 lein repl 中需要 core.async

require core.async in a lein repl

在新的 lein (~2.5) repl 中,我输入:

 (require '[clojure.string :as string])

而且我可以按预期使用字符串。但是,当尝试像这样要求 core.asnc 时,我收到一条错误消息:

(require '[clojure.core.async :as ca])
FileNotFoundException Could not locate clojure/core/async__init.class or clojure/core/async.clj on classpath.  clojure.lang.RT.load (RT.java:449)

感谢您的回答,我现在设法在运行时使用石榴或 alembic 在 repl 中要求任意库。但是宏呢?例如,如何在 repl 中获取 'go' 宏?没有类似 (require-macros ... 类似于在项目的 ns 声明中需要 core.async 时采用的方法。

core.async 不是 clojure.core 库的一部分。您需要将 core.async jar 或源添加到类路径中。最简单的方法是通过 project.clj 使用依赖项,但也有像 pomegranate and alembic 这样的工具可以在运行时执行此操作,可以将其添加到本地 profiles.clj.