This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-14
Channels
- # announcements (11)
- # babashka (82)
- # beginners (51)
- # calva (11)
- # cider (3)
- # clj-kondo (62)
- # cljdoc (10)
- # cljs-dev (22)
- # clojure (75)
- # clojure-boston (1)
- # clojure-brasil (3)
- # clojure-czech (4)
- # clojure-europe (49)
- # clojure-france (10)
- # clojure-italy (16)
- # clojure-nl (5)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (33)
- # conjure (12)
- # core-async (6)
- # cursive (2)
- # datalevin (7)
- # datomic (6)
- # graalvm (13)
- # gratitude (2)
- # honeysql (3)
- # introduce-yourself (1)
- # lsp (37)
- # nextjournal (62)
- # off-topic (29)
- # pathom (1)
- # quil (2)
- # reitit (4)
- # releases (2)
- # sci (1)
- # shadow-cljs (28)
- # spacemacs (10)
- # sql (1)
- # tools-build (3)
- # vim (3)
I'm trying to get a shadow-cljs project running under Calva. Everything seems to be working up through jack-in, but when I look at the terminal output, I get the message:
[:app] Build failure:
The required namespace "atlas.main" is not available.
However, my .cljs file is set up in src/atlas/main.cljs and has the proper namespace declared:
(ns atlas.main)
(defn main![]
(println "Hello, world!"))
(defn reload! []
(println "Code updated!."))
I believe my shadow-cljs.edn file is also set up correctly, with the following entries:
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/atlas"
"src/test"]
:dependencies
[]
:dev-http {32456 "public"}
:builds
{:app {:output-dir "public/js"
:asset-path "."
:target :browser
:modules {:main {:init-fn atlas.main/main!}}
:devtools {:after-load atlas.main/reload!}}}}
Any ideas why I'm getting the error during jack-in?I think it is that you. have the source path src/atlas
but in there you have main.cljs
, then the namespace doesn't match the path. Try putting main.cljs
in src/atlas/atlas/
.
You might also get away with having source-patsh ["src", "dev", "test"]
and place atlas
directories in src
and test
. (If you don't like the atlas/atlas
layout.)
I’ve tripped on it too. It happens because Calva helpfully infers the namespace without checking the src path specification in shadow-cljs.edn. It might be better if Calva checked that file on shadow-cljs projects or asked the user what the src path is before jumping to conclusions about what the ns should be. Just a thought.
Calva makes no assumptions here. You would end up in the same place just using shadow without any editor involved.
Calva suggests (ns atlas.main), but if it looked at shadow-cljs.edn, it would know that the src path was specified as src/atlas and could therefore suggest (ns main) instead. Or am I missing something? Not a big deal, of course, since once you’ve been bitten by this, you know immediately how to fix it.