0
votes

I'm trying to open the Clojure repl using leiningen. When I open it from the console in my project directory I get an error, but using lein run everything works correctly. Also if I start lein repl in a non project directory it works correctly.

What is causing this???

$ lein repl
#error {
 :cause Don't know how to create ISeq from: java.lang.Character
 :via
 [{:type java.lang.IllegalArgumentException
   :message Don't know how to create ISeq from: java.lang.Character
   :at [clojure.lang.RT seqFrom RT.java 542]}]
 :trace
 [[clojure.lang.RT seqFrom RT.java 542]
  [clojure.lang.RT seq RT.java 523]
  [clojure.core$seq__4357 invokeStatic core.clj 137]
  [clojure.core$concat$fn__4446 invoke core.clj 706]
  [clojure.lang.LazySeq sval LazySeq.java 40]
  [clojure.lang.LazySeq seq LazySeq.java 49]
  [clojure.lang.Cons next Cons.java 39]
  [clojure.lang.RT boundedLength RT.java 1749]
  [clojure.lang.RestFn applyTo RestFn.java 130]
  [clojure.core$apply invokeStatic core.clj 648]
  [clojure.core$load_libs invokeStatic core.clj 5778]
  [clojure.core$load_libs doInvoke core.clj 5758]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 648]
  [clojure.core$require invokeStatic core.clj 5796]
  [clojure.core$require doInvoke core.clj 5796]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [user$eval5 invokeStatic form-init8518282048677853666.clj 1]
  [user$eval5 invoke form-init8518282048677853666.clj 1]
  [clojure.lang.Compiler eval Compiler.java 6927]
  [clojure.lang.Compiler eval Compiler.java 6916]
  [clojure.lang.Compiler eval Compiler.java 6916]
  [clojure.lang.Compiler load Compiler.java 7379]
  [clojure.lang.Compiler loadFile Compiler.java 7317]
  [clojure.main$load_script invokeStatic main.clj 275]
  [clojure.main$init_opt invokeStatic main.clj 277]
  [clojure.main$init_opt invoke main.clj 277]
  [clojure.main$initialize invokeStatic main.clj 308]
  [clojure.main$null_opt invokeStatic main.clj 342]
  [clojure.main$null_opt invoke main.clj 339]
  [clojure.main$main invokeStatic main.clj 421]
  [clojure.main$main doInvoke main.clj 384]
  [clojure.lang.RestFn invoke RestFn.java 421]
  [clojure.lang.Var invoke Var.java 383]
  [clojure.lang.AFn applyToHelper AFn.java 156]
  [clojure.lang.Var applyTo Var.java 700]
  [clojure.main main main.java 37]]}
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol, compiling:(/tmp/form-init8518282048677853666.clj:1:73)
    at clojure.lang.Compiler.load(Compiler.java:7391)
    at clojure.lang.Compiler.loadFile(Compiler.java:7317)
    at clojure.main$load_script.invokeStatic(main.clj:275)
    at clojure.main$init_opt.invokeStatic(main.clj:277)
    at clojure.main$init_opt.invoke(main.clj:277)
    at clojure.main$initialize.invokeStatic(main.clj:308)
    at clojure.main$null_opt.invokeStatic(main.clj:342)
    at clojure.main$null_opt.invoke(main.clj:339)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
    at clojure.lang.RT$1.invoke(RT.java:239)
    at user$eval5.invokeStatic(form-init8518282048677853666.clj:1)
    at user$eval5.invoke(form-init8518282048677853666.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6927)
    at clojure.lang.Compiler.eval(Compiler.java:6916)
    at clojure.lang.Compiler.eval(Compiler.java:6916)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    ... 14 more
Exception in thread "Thread-3" clojure.lang.ExceptionInfo: Subprocess failed {:exit-code 1}
    at clojure.core$ex_info.invokeStatic(core.clj:4617)
    at clojure.core$ex_info.invoke(core.clj:4617)
    at leiningen.core.eval$fn__5732.invokeStatic(eval.clj:264)
    at leiningen.core.eval$fn__5732.invoke(eval.clj:260)
    at clojure.lang.MultiFn.invoke(MultiFn.java:233)
    at leiningen.core.eval$eval_in_project.invokeStatic(eval.clj:366)
    at leiningen.core.eval$eval_in_project.invoke(eval.clj:356)
    at leiningen.repl$server$fn__11838.invoke(repl.clj:243)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:646)
    at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1881)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1881)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invokeStatic(core.clj:650)
    at clojure.core$bound_fn_STAR_$fn__4671.doInvoke(core.clj:1911)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.lang.Thread.run(Unknown Source)

REPL server launch timed out

And here is my actual core.clj file:

(ns app.core)

(defn gcd 
  ([b c] (gcd b c b c))
  ([b c d e] 
      (cond (> b c) (recur (- b c) c d e) 
          (< b c) (recur b (- c b) d e) 
          :else (println b (/ b d) (/ b e)))))


(defn -main [& args]

  (gcd 164642622978589800 78499828003450)

)

and here is my project.clj file:

(defproject app "0.1.0-SNAPSHOT"
  :main "app.core"
  :description "First Application"
  :url ""
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  )
1
Not your problem, but you should return the gcd instead of printing it.Carcigenicate
Can reproduce on my computer.Carcigenicate

1 Answers

1
votes

2 issues:

  1. You need a gen-class directive in the ns macro. This should have caused your lein run to fail (it failed for me without it). Note: In the comments, Arthur said it isn't necessary in this case. I consider him far more authoritative, so it looks like it's not necessary. The error I got must have been due to my IDE. I assumed it was an "entry point" error because I couldn't remember what the message was exactly.

  2. (Your main problem) In project.clj, you're using a string to indicate the main. Clojure expects that it will be a symbol.


(ns app.core
  (:gen-class)) ; 1.

(defn gcd
  ([b c] (gcd b c b c))
  ([b c d e]
   (cond (> b c) (recur (- b c) c d e)
         (< b c) (recur b (- c b) d e)
         :else (println b (/ b d) (/ b e)))))


(defn -main [& args]

  (gcd 164642622978589800 78499828003450))

Project.clj:

(defproject app "0.1.0-SNAPSHOT"
  :main app.core ; 2.
  :description "First Application"
  :url ""
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]])