Fork me on GitHub

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


 :dev-http {32456 "public"}
 {: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.)


Thanks. Switching the source path to src worked.


Awesome. Can't tell you how often I have tripped on that.


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.


Not sure Calva suggests that. Haven't tried. But if it does, it is clojure-lsp. 😃




atlas.main is indeed suggested. Should probably be filed as an issue on clojure-lsp.