clojurescript could not locate cljs.core.async.macros
Asked Answered
A

5

6

I have the following code in the file client.cljs :

(ns onn.client
    (:require [enfocus.core :as ef]
          [enfocus.effects :as effects]
          [enfocus.events :as events]
          [clojure.browser.repl :as repl]
          [goog.net.XhrIo :as xhr]
          [cljs.core.async :as async :refer [chan close!]])
    (:use-macros [enfocus.macros :only [deftemplate defsnippet defaction]])
    (:require-macros [cljs.core.async.macros :refer [go alt!]]
))
;....the actual code follows

The project file looks like this:

(defproject onn "DEV-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://exampl.com/FIXME"
  :dependencies [[org.clojure/clojure "1.5.1"]
             [ring/ring-core "1.1.8"]
             [ring/ring-jetty-adapter "1.1.8"]
             [org.clojure/clojurescript "0.0-1820"]
             [org.clojure/core.async "0.1.0-SNAPSHOT"]
             [enfocus "2.0.0-SNAPSHOT"]]
  :plugins [[lein-cljsbuild "0.3.2"]
            [lein-ring "0.8.3"]]
  :cljsbuild {:builds [{:source-paths ["src"],
                    :compiler {:pretty-print true,
                               :output-to "resources/public/js/main.js",
                               :warnings true,
                               :optimizations :whitespace}}]}
  :ring {:handler onn.server/app :port 3000})

...when compiled gives me this error:

Caused by: clojure.lang.ExceptionInfo: 
Could not locate cljs/core/async/macros__init.class or cljs/core/async/macros.clj 
on classpath:  at line 1 src/onn/client.cljs

Note that my code is copied from here: https://github.com/Dimagog/AsyncGET/blob/master/cljs/app.cljs This guy's project has the same dependencies and it works.

Any idea why? Thanks!

UPDATE: My cljsbuild was on auto. After restarting cljsbuild it compiles just fine. Thanks!

Alexandrina answered 4/11, 2013 at 14:25 Comment(2)
Did you restart lein cljsbuild after modifying project.clj?Fugate
I didn't. My cljsbuild was on auto! After restarting cljsbuild it workedAlexandrina
A
0

cljsbuild was on auto. After restarting cljsbuild it compiled just fine

Alexandrina answered 11/10, 2017 at 11:38 Comment(0)
A
6

I got this error when I was (mistakenly) using :include-macros true in my require for cljs.core.async:

;; THROWS ERROR
(ns my-ns
  (:require [cljs.core.async :refer [<!] :include-macros true])
  (:require-macros [cljs.core.async.macros :refer [go]]))

Removing it worked:

;; DOES NOT THROW ERROR
(ns my-ns
  (:require [cljs.core.async :refer [<!]])
  (:require-macros [cljs.core.async.macros :refer [go]]))
Asafetida answered 3/12, 2014 at 20:31 Comment(1)
FYI, this is because the macros moved to cljs.core.async.macros.Peeper
H
3

Your project.clj file looks to be missing the repository that the AsyncGET project used.

:repositories { "sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/" }
Heptad answered 4/11, 2013 at 15:15 Comment(4)
...or use the proper Maven release [org.clojure/core.async "0.1.242.0-44b1e3-alpha"] - but this is the way to go if you want the bleeding edge of core.asyncFrasier
Generally true, except he based his code on another project that used the SNAPSHOT version. In this case, it's better to get the code working first, before switching to a "proper Maven release".Heptad
Clearly true - this is why I haven't answered on my own, I just wanted to notice that. In general it's not really good practice to use SNAPSHOT releases because they will automatically be updated and thus mess with your version control. E. g. an earlier commit may be unusable because it was working only with an earlier snapshot.Frasier
It worked the same even if I add the :repositories. It seems the cljsbuild had to be restarted. ThanksAlexandrina
M
1

I have ran into this also. Running lein cljsbuild clean enabled cljsbuild to pull in the library and build successfully.

Mitsukomitt answered 11/8, 2014 at 3:48 Comment(1)
Something like this fixes it. As you can see the UPDATE section, the build was the problem. I was running a long lived "lein cljsbuild auto" in the background. Once I restarted the cljsbuild everything was normal.Alexandrina
S
0

Only if your error is related with the brepl ...

If you are trying to use this code into the "standard" clojurescript brepl, first you need to evaluate the clojure macros code into the repl, and then the async macros will be available from the brepl. Also, You can try for interactive coding on the brepl the @cemerick/austin tool https://github.com/cemerick/austin

Smacker answered 4/11, 2013 at 23:4 Comment(0)
A
0

cljsbuild was on auto. After restarting cljsbuild it compiled just fine

Alexandrina answered 11/10, 2017 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.