0
votes
  • clojure version: 1.8.0
  • leiningen version: 2.7.1
  • jdk version: 1.8.0_101

When I require a library, say reagent(has added in the project dependencies), in the lein repl:

user=> (require '[reagent.core :as r])
nil

The output is nil, which I think it means success. But when I use the r,say (r/atom 3), the repl throw an error says:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: r in
this context, compiling:  (/private/var/folders/_y/n3ym4ftj2ld9tl471g_kcv_00000gn/T
/form-init1002540725014588615.clj:1:4923) 

That seems strange. Anyone has some idea?

By the way, I can require java and clojure library.

1
Reagent is mainly a ClojureScript library. The core namespace only has a utility macro. Are you running this from a ClojureScript REPL?Michiel Borkent
Can you elaborate on what you mean by when I use the r ... HOW are you using it? Just typing r and pressing the enter key in the REPL will cause this error, because r is not a symbol. You need to refer to a symbol, like: (r/my-function ... So, it's hard to say what your problem is without further information.Josh
@MichielBorkent Yes, that is an embrassment, I might ignored the difference of clojure REPL and clojurescript REPL..minddy

1 Answers

1
votes

Probably you are trying to use ClojureScript library: reagent within the Clojure REPL. Finding the cause to error is not that useful since Clojure and ClojureScript are suppose to run in very different environments, JVM and JavaScript respectively. But same attempt will succeed in ClojureScript context.

As a test, create a ClojureScript project based on figwheel template.

lein new figwheel rtest
cd rtest

Add the regent dependency in project.clj

:dependencies [[org.clojure/clojure "1.8.0"]
               [reagent "0.6.0"] ; only add this line

Run the project

rlwrap lein figwheel

You will be connected to the browser repl automatically. Otherwise browse to http://localhost:3449/index.html to get connected.

Now you can retry what you did.

cljs.user=> (require '[reagent.core :as r])
nil
cljs.user=> (type r/render-component)
#object[Function "function Function() { [native code] }"]