Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected Difficulties with "Hello, World!"

I would like to learn Clojure and I've downloaded and set up the following gizmos:

  • Clojure 1.6.0 from official site;
  • Leiningen 2.4.3;
  • Cider 0.6.0 from GitHub.

I've got it working. Now I'm trying to print message "Hello, World!", while running Cider from within Emacs:

; CIDER 0.6.0 (Java 1.7.0_65, Clojure 1.6.0, nREPL 0.2.0-beta5)
user> (println "Hello World!")
Hello World!NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I
clojure.tools.nrepl.middleware.session/session-out/fn--7630
(session.clj:43)NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I
clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)
user> 

What is this noise all about? When I just run:

$ clojure
;Clojure 1.6.0
user=> (println "Hello, World!")
Hello, World!
nil

everything is fine. When I do it with Leiningen:

$ lein repl
; lotsa stuff here...
user=> (println "Hello, World!")

After entering of this command I relish the following poetry:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: rprintln in this context, compiling:(NO_SOURCE_PATH:1:1) NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I  clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)
Exception in thread "nREPL-worker-3" java.lang.NoSuchMethodError: clojure.tools.nrepl.StdOutBuffer.length()I
    at clojure.tools.nrepl.middleware.session$session_out$fn__7630.doInvoke(session.clj:43)
    at clojure.lang.RestFn.invoke(RestFn.java:460)
    at clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$ff19274a.write(Unknown Source)
    at java.io.PrintWriter.write(PrintWriter.java:456)
    at java.io.PrintWriter.write(PrintWriter.java:473)
    at clojure.core$fn__5471.invoke(core_print.clj:191)
    at clojure.lang.MultiFn.invoke(MultiFn.java:231)
    at clojure.core$pr_on.invoke(core.clj:3392)
    at clojure.core$pr.invoke(core.clj:3404)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$prn.doInvoke(core.clj:3437)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$println.doInvoke(core.clj:3457)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.main$repl_caught.invoke(main.clj:158)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569$fn__7582.invoke(interruptible_eval.clj:76)
    at clojure.main$repl$fn__6634.invoke(main.clj:259)
    at clojure.main$repl.doInvoke(main.clj:257)
    at clojure.lang.RestFn.invoke(RestFn.java:1096)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569.invoke(interruptible_eval.clj:56)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:41)
    at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__7610$fn__7613.invoke(interruptible_eval.clj:171)
    at clojure.core$comp$fn__4192.invoke(core.clj:2402)
    at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__7603.invoke(interruptible_eval.clj:138)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Oh, Nooo. What a pain! Stop it, stop it!


I'm so perplexed. What is it and how do I fix this? Has anyone similar experience? How do I print "Hello, World!" in Clojure?

like image 490
Mark Karpov Avatar asked Aug 20 '14 06:08

Mark Karpov


1 Answers

I can reproduce this error with leinengen 2.4.3. You can run lein upgrade 2.4.2 to get the most recent version that actually works. It's unusual for the leiningen team to mark a bad build like this as stable, at first I suspected cider. By the way, the "stable" version of cider should be 0.7.0.

like image 54
noisesmith Avatar answered Oct 29 '22 15:10

noisesmith