How to get to run a minimal Clojure app with boot-clj and Emacs?
I installed the Boot application and ran boot -h
twice. Then I got this
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:~$
My Emacs is of the version as follows
GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian
I installed cider
, clojure-mode
and projectile
.
I configured Emacs with a tutorial of this https://github.com/boot-clj/boot/wiki/Cider-REPL#a-better-way and got a configuration file:
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:~$
Then I typed out this
C-x C-f ~/Dropbox/Clojure/myapp2/src/myapp2/core.clj
and the file opened.
Here you are the file's code:
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:~$
The file is in a project generated by a boot-clj command boot -d boot/new new -t app -n myapp2
Then I typed out this M-x cider-jack-in
and got an error:
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
But when I removed the
'(cider-boot-parameters (quote "cider repl -s wait"))
line from the configuration, restarted Emacs, run cider-jack-in
, cider started successfully. So I could run Clojure commands such as (range 5)
etc.
But when I tried to run the application and put out (-main)
it crashed and an info that an error took place and the main
symbol could not be resolved:
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
So it looks like cider cannot find the -main
function. Perhaps I should type cider-jack-in
command in another place? But where? And the cider-boot-parameters
issue is also strange. How to run any Clojure application with boot-clj and emacs-25. (The problem occurred also at emacs26 and emacs27).