Windows10下Leiningen REPL执行(require 'examples.introduction)报FileNotFound异常求助
解决(require 'examples.introduction)的FileNotFound异常问题
核心问题原因
Leiningen 不会直接读取系统级的CLASSPATH环境变量,它依赖自身的项目配置来管理类路径。你当前设置的系统CLASSPATH对Leiningen REPL无效。
具体解决步骤
确认文件结构正确性
确保introduction.clj文件的路径是C:\Users\easte\shcloj3-code\code\src\examples\introduction.clj——Clojure的命名空间examples.introduction必须对应src/examples/introduction.clj的文件路径,层级要严格匹配。配置Leiningen项目的源码路径
进入C:\Users\easte\shcloj3-code\code目录(确保该目录下存在project.clj文件),打开project.clj,在配置中添加或修正:source-paths项:(defproject your-project-name "0.1.0-SNAPSHOT" :description "Your project description" :url "https://example.com" :license {:name "EPL-2.0" :url "https://www.eclipse.org/legal/epl-2.0/"} :dependencies [[org.clojure/clojure "1.11.1"]] :source-paths ["src"]) ; 如果你的源码根目录是code/src,就改成["code/src"]重启Leiningen REPL
关闭当前运行的REPL,在C:\Users\easte\shcloj3-code\code目录下重新执行lein repl,之后再运行(require 'examples.introduction)即可正常加载。临时应急方案(不推荐长期使用)
若不想修改project.clj,可在启动REPL时手动追加类路径:lein repl -i "(set! *classpath* (str *classpath* \";C:\\Users\\easte\\shcloj3-code\\code\\src\"))"注意Windows路径中的反斜杠需要转义为
\\,启动后再执行(require 'examples.introduction)即可。
内容的提问来源于stack exchange,提问作者Slavko Vorkapitch
相关产品推荐
相关产品推荐

