user=> my-nonexistent-name
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: my-nonexistent-name in this context
This section lists common issues when using the REPL, and how to diagnose them:
Symptoms:
user=> my-nonexistent-name
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: my-nonexistent-name in this context
Explanations:
Maybe you made a typo in the Var name, e.g you should have written my-non-existent-name
instead of my-nonexistent-name
.
Maybe you forgot to define my-nonexistent-name
in the REPL (using e.g def
or defn
):
this could happen if you wrote a (def my-nonexistent-name …)
in your code file but forgot to evaluate it in the REPL.
Maybe you defined my-non-existent-name
, but in another namespace.
You should either write myapp.ns23/my-non-existent-name
or switch to namespace myapp.ns23/my-non-existent-name
.
Symptoms:
user=> ns3/foo-bar
Syntax error compiling at (REPL:0:0).
No such namespace: ns3
Explanations:
Maybe you made a typo in the namespace alias, e.g you should have written n3/foo-bar
instead of ns3/foo-bar
Maybe you have never defined the ns3
alias in the current namespace:
you can fix that by evaluating (require '[myapp.ns3 :as ns3])
Maybe you have defined the ns3
alias, but in a different namespace that the one your REPL is in at the moment.
Symptoms:
$ clj
Clojure 1.10.0
user=> clojure.set/union
Syntax error (ClassNotFoundException) compiling at (REPL:0:0).
clojure.set
Explanations:
You are using a namespace that has yet not been created in the REPL.
Note that the error message (‘ClassNotFoundException’) is particularly confusing in this case:
the reason is that the Clojure compiler, having found no loaded namespace named clojure.set
,
is trying to interpret clojure.set as a Java class. The solution is to make sure the clojure.set
lib has been loaded.
Symptoms:
user=> (require '[a.b.c])
Execution error (FileNotFoundException) at user/eval161 (REPL:1).
Could not locate a/b/c__init.class, a/b/c.clj or a/b/c.cljc on classpath.
Explanations: Clojure did not find any existing namespace named a.b.c
, then searched the classpath
for a lib that would define it, eventualling failing with the above Exception.
The cause may vary:
maybe you just made a typo in the namespace name
maybe you forgot to add the lib to your classpath, which is usually done by adding it to
the configuration of your project’s dependencies (e.g in the deps.edn
or project.clj
file),
and sometimes (depending on the project management tool) running an installation command (e.g lein deps
).
maybe you did add the library to the classpath, but that was after you started the REPL: in this case, you should re-start the REPL.