如何通过boot-clj和Emacs运行最小的Clojure应用程序?
我安装了Boot应用程序并运行boot -h
两次。然后我得到了
s@Lux:~$ boot -V
#http://boot-clj.com
#Mon Feb 04 00:23:28 CET 2019
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.8.0
BOOT_VERSION=2.8.2
s@Lux:~$
我的Emacs的版本如下
GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian
我安装了cider
,clojure-mode
和projectile
。
我使用此https://github.com/boot-clj/boot/wiki/Cider-REPL#a-better-way的教程配置了Emacs 并得到一个配置文件:
s@Lux:~$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
'(cider-boot-parameters (quote "cider repl -s wait"))
'(package-selected-packages (quote (projectile clojure-mode-extra-font-locking cider))))
s@Lux:~$
然后我输入
C-x C-f ~/Dropbox/Clojure/myapp2/src/myapp2/core.clj
并打开文件。
这是文件的代码:
s@Lux:~$ cat ~/Dropbox/Clojure/myapp2/src/myapp2/core.clj
(ns myapp2.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
s@Lux:~$
该文件位于由boot-clj命令boot -d boot/new new -t app -n myapp2
生成的项目中
然后我输入了此M-x cider-jack-in
并收到错误消息:
line: 1
error in process sentinel: Could not start nREPL server: Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
java.lang.Thread.run Thread.java: 748
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 624
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1149
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/binding-conveyor-fn/fn core.clj: 1938
boot.core/boot/fn core.clj: 1032
boot.core/run-tasks core.clj: 1022
boot.task.built-in/fn/fn/fn/fn built_in.clj: 492
clojure.core/deref core.clj: 2228
...
boot.task.built-in/fn/fn/fn built_in.clj: 489
clojure.core/apply core.clj: 646
...
boot.core/launch-nrepl core.clj: 1313
boot.repl/launch-nrepl repl.clj: 60
boot.repl-server/start-server repl_server.clj: 68
boot.repl-server/->mw-list repl_server.clj: 59
...
clojure.core/mapcat core.clj: 2674 (repeats 2 times)
clojure.core/apply core.clj: 646
...
clojure.core/map/fn core.clj: 2644
boot.repl-server/->mw-list repl_server.clj: 55
boot.repl-server/->var repl_server.clj: 49
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5736
clojure.core/load-lib/fn core.clj: 5737
clojure.core/load-one core.clj: 5697
...
clojure.core/load core.clj: 5876
clojure.core/load core.clj: 5892
clojure.core/load/fn core.clj: 5893
...
refactor-nrepl.middleware/eval2021 middleware.clj: 1
refactor-nrepl.middleware/eval2021/loading--auto-- middleware.clj: 1
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5736
clojure.core/load-lib/fn core.clj: 5737
clojure.core/load-one core.clj: 5697
...
clojure.core/load core.clj: 5876
clojure.core/load core.clj: 5892
clojure.core/load/fn core.clj: 5893
...
refactor-nrepl.ns.resolve-missing/eval14613 resolve_missing.clj: 1
refactor-nrepl.ns.resolve-missing/eval14613/loading--auto-- resolve_missing.clj: 1
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5755
clojure.core/apply core.clj: 648
...
clojure.core/refer core.clj: 4087
clojure.core/refer core.clj: 4119
java.lang.IllegalAccessError: info-clj does not exist
clojure.lang.ExceptionInfo: info-clj does not exist
line: 1
但是当我删除
'(cider-boot-parameters (quote "cider repl -s wait"))
从配置开始行,重新启动Emacs,运行cider-jack-in
,苹果酒成功启动。所以我可以运行Clojure命令,例如(range 5)
等。
但是,当我尝试运行该应用程序并放出(-main)
时,它崩溃了,并且提示发生了错误,并且无法解析main
符号:
user> (-main)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: -main in this context, compiling:(*cider-repl Clojure/myapp2:localhost:45545(clj)*:43:7)
user>
Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (24 frames hidden)
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling *cider-repl Clojure/myapp2:localhost:45545(clj)* at (43:7)
Compiler.java: 6688 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 3766 clojure.lang.Compiler$InvokeExpr/parse
Compiler.java: 6870 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 6001 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5380 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 3972 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 6866 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6924 clojure.lang.Compiler/eval
Compiler.java: 6890 clojure.lang.Compiler/eval
core.clj: 3105 clojure.core/eval
core.clj: 3101 clojure.core/eval
main.clj: 240 clojure.main/repl/read-eval-print/fn
main.clj: 240 clojure.main/repl/read-eval-print
main.clj: 258 clojure.main/repl/fn
main.clj: 258 clojure.main/repl
main.clj: 174 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 83 nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 1881 clojure.core/with-bindings*
core.clj: 1881 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 81 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 50 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 221 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 189 nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/run
1. Caused by java.lang.RuntimeException
Unable to resolve symbol: -main in this context
Util.java: 221 clojure.lang.Util/runtimeException
Compiler.java: 7164 clojure.lang.Compiler/resolveIn
Compiler.java: 7108 clojure.lang.Compiler/resolve
Compiler.java: 7069 clojure.lang.Compiler/analyzeSymbol
Compiler.java: 6648 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 3766 clojure.lang.Compiler$InvokeExpr/parse
Compiler.java: 6870 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 6001 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5380 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 3972 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 6866 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6924 clojure.lang.Compiler/eval
Compiler.java: 6890 clojure.lang.Compiler/eval
core.clj: 3105 clojure.core/eval
core.clj: 3101 clojure.core/eval
main.clj: 240 clojure.main/repl/read-eval-print/fn
main.clj: 240 clojure.main/repl/read-eval-print
main.clj: 258 clojure.main/repl/fn
main.clj: 258 clojure.main/repl
main.clj: 174 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 83 nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 1881 clojure.core/with-bindings*
core.clj: 1881 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 81 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 50 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 221 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 189 nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/ Show: Project-Only All
所以看来苹果酒找不到-main
函数。也许我应该在另一个地方键入cider-jack-in
命令?但是哪里? cider-boot-parameters
问题也很奇怪。如何使用boot-clj和emacs-25运行任何Clojure应用程序。 (该问题也发生在emacs26和emacs27上。)
答案 0 :(得分:1)
我重新安装了Debian,安装了启动程序和emacs25。
然后创建一个配置文件:
s@Windown:~/Dropbox/Clojure/myapp2$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(cider-boot-parameters (quote "repl -s wait"))
'(package-selected-packages
(quote
(clojure-mode projectile clojure-mode-extra-font-locking cider))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
s@Windown:~/Dropbox/Clojure/myapp2$
然后安装了苹果酒,clojure模式和弹丸。然后它起作用了。
s@Windown:~/Downloads2$ boot -V
#http://boot-clj.com
#Mon Feb 04 13:34:49 CET 2019
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.8.0
BOOT_VERSION=2.8.2
s@Windown:~/Downloads2$
This is GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian
Emacs Package Library
projectile 20190126.1117 installed Manage and navigate projects in Emacs easily
clojure-mode 20190105.1043 installed Major mode for Clojure code
cider 20190125.1339 installed Clojure Interactive Development Environment that Rocks