Can't evaluate when file require libs
If i evaluate a file thats requires any lib, it returns a java.io.FileNotFoundException. This is the test script i'm using:
(ns clj-init.core (:require [java-time :as t]))
(defn test-01 [] (println (t/local-date-time)))
and this is the exception it returns:
java.io.FileNotFoundException: Could not locate java_time__init.class, java_time.clj or java_time.cljc on classpath. Please check that namespaces with dashes use underscores in the
It works just fine if i run it on lein repl or Intellij Cursive
Does someone have any ideia on how can i fix it?
I suspect it depends on a way you start your nREPL server. It must include this library on the classpath. How do you start it?
Hi! I ran into a similar issue.
I created draft project with some external libraries and started nrepl with lein repl inside. When I use library with alias in namespace and try to run some function I get an exception: No such namespace: 'alias-name'. Please look on screenshot below:
But in repl everything is fine:

Maybe I'm doing something wrong?
Just checked — new project with lein new draft, added [org.clojure/data.json "2.4.0"], lein repl and connect. Works for me.
What lein/nREPL version are you on?
Leiningen 2.9.10 on Java 18.0.2 OpenJDK 64-Bit Server VM
REPL-y 0.5.1, nREPL 0.9.0
I also bumped the Clojure version but the result is the same: No such namespace
Ok, can you
- Run
Preferences: Clojure Sublimed Settings - Add
"debug": true, - Connect
- Try to eval ns form
- Try to eval json/read-str form
Then open console (ctrl+tilde) and paste here what’s being send to and from nREPL?
eval ns form:
SND {'op': 'clone-eval-close', 'code': '(ns draft.core\n (:require [clojure.data.json :as json]\n [loom.graph :as gr]))\n', 'ns': 'user', 'file': '/Users/kuzmo/Documents/Work/_drafts/draft/src/draft/core.clj', 'id': 14, 'nrepl.middleware.caught/caught': 'clojure-sublimed.middleware/print-root-trace', 'nrepl.middleware.print/print': 'clojure-sublimed.middleware/pprint', 'nrepl.middleware.print/quota': 1024, 'session': '96a7a8cc-7c21-474f-8745-066fc7662375'}
RCV {'id': 14, 'new-session': 'a2b460d6-a6bd-49cc-840c-fda12cdcffe8', 'session': '96a7a8cc-7c21-474f-8745-066fc7662375', 'status': ['done']}
RCV {'clojure-sublimed.middleware/time-taken': 30189250, 'id': 14, 'ns': 'draft.core', 'session': 'a2b460d6-a6bd-49cc-840c-fda12cdcffe8', 'value': 'nil\n'}
RCV {'id': 14, 'session': 'a2b460d6-a6bd-49cc-840c-fda12cdcffe8', 'status': ['done']}
RCV {'id': 14, 'session': 'a2b460d6-a6bd-49cc-840c-fda12cdcffe8', 'status': ['done', 'session-closed']}
eval json/read-str form:
SND {'op': 'clone-eval-close', 'code': 'json/read-str', 'ns': 'user', 'line': 5, 'file': '/Users/kuzmo/Documents/Work/_drafts/draft/src/draft/core.clj', 'id': 15, 'nrepl.middleware.caught/caught': 'clojure-sublimed.middleware/print-root-trace', 'nrepl.middleware.print/print': 'clojure-sublimed.middleware/pprint', 'nrepl.middleware.print/quota': 1024, 'session': '96a7a8cc-7c21-474f-8745-066fc7662375'}
RCV {'id': 15, 'new-session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c', 'session': '96a7a8cc-7c21-474f-8745-066fc7662375', 'status': ['done']}
RCV {'id': 15, 'out': 'java.lang.RuntimeException: No such namespace: json\n at clojure.lang.Util.runtimeException (Util.java:221)\n clojure.lang.Compiler.resolveIn (Compiler.java:7401)\n clojure.lang.Compiler.resolve (Compiler.java:7375)\n clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)\n clojure.lang.Compiler.analyze (Compiler.java:6785)\n clojure.lang.Compiler.analyze (Compiler.java:6762)\n clojure.lang.Compiler.eval (Compiler.java:7198)\n clojure.lang.Compiler.eval (Compiler.java:7149)\n clojure.core$eval.invokeStatic (core.clj:3215)\n clojure.core$eval.invoke (core.clj:3211)\n nrepl.middleware.interruptible_eval$evaluate$fn__2879$fn__2880.invoke (interruptible_eval.clj:87)\n clojure.lang.AFn.applyToHelper (AFn.java:152)\n clojure.lang.AFn.applyTo (AFn.java:144)\n clojure.core$apply.invokeStatic (core.clj:667)\n clojure.core$with_bindings_STAR_.invokeStatic (core.clj:1990)\n clojure.core$with_bindings_STAR_.doInvoke (core.clj:1990)\n clojure.lang.RestFn.invoke (RestFn.java:425)\n nrepl.', 'session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c'}
RCV {'clojure-sublimed.middleware/column': 1752, 'clojure-sublimed.middleware/line': 1, 'clojure-sublimed.middleware/root-ex-class': 'RuntimeException', 'clojure-sublimed.middleware/root-ex-msg': 'No such namespace: json', 'clojure-sublimed.middleware/source': '/Users/kuzmo/Documents/Work/_drafts/draft/src/draft/core.clj', 'clojure-sublimed.middleware/trace': 'RuntimeException: No such namespace: json\n\tclojure.lang.Util.runtimeException (Util.java:221)', 'ex': 'class clojure.lang.Compiler$CompilerException', 'id': 15, 'root-ex': 'class clojure.lang.Compiler$CompilerException', 'session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c', 'status': ['eval-error']}
RCV {'id': 15, 'out': 'middleware.interruptible_eval$evaluate$fn__2879.invoke (interruptible_eval.clj:87)\n clojure.main$repl$read_eval_print__9206$fn__9209.invoke (main.clj:437)\n clojure.main$repl$read_eval_print__9206.invoke (main.clj:437)\n clojure.main$repl$fn__9215.invoke (main.clj:458)\n clojure.main$repl.invokeStatic (main.clj:458)\n clojure.main$repl.doInvoke (main.clj:368)\n clojure.lang.RestFn.invoke (RestFn.java:1523)\n nrepl.middleware.interruptible_eval$evaluate.invokeStatic (interruptible_eval.clj:84)\n nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:56)\n nrepl.middleware.interruptible_eval$interruptible_eval$fn__2912$fn__2916.invoke (interruptible_eval.clj:152)\n clojure.lang.AFn.run (AFn.java:22)\n nrepl.middleware.session$session_exec$main_loop__2982$fn__2986.invoke (session.clj:218)\n nrepl.middleware.session$session_exec$main_loop__2982.invoke (session.clj:217)\n clojure.lang.AFn.run (AFn.java:22)\n java.lang.Thread.run (Thread.java:833)\n', 'session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c'}
RCV {'id': 15, 'session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c', 'status': ['done']}
RCV {'id': 15, 'session': '7a7f421d-fa6b-4c26-a0ae-4dedf91cd98c', 'status': ['done', 'session-closed']}
Oh shit, I think I know what’s going on. Are you using Clojure: Sublimed syntax for the file? Parser depends on it (unfortunately, will decouple it in the future #24)
Oh, I was sure that Clojure: Sublimed was selected. Sorry for wasting time, now it works.
Just for others: "Syntax > Open all with current extension > Clojure Sublimed" might show a checkmark, but that can still be overruled for your particular file that you have open now, if you earlier set the syntax for that file to Clojure. So also check "Syntax > Clojure >", which would get you back to the same problem as mentioned above.