Clojure no cljc file required

I need to split the namespace between my Clojure (garden) and my ClojureScript (reagent).

Currently, the project folder is as follows:

src/ clj/ name/ css.clj cljs/ name/ core.cljs cljc/ name/ config.cljc 

The config.cljc file has the following namespace: (ns name.config) .

I tried to reference this namespace from within clj/name/css.clj with the requirement.

 (ns name.css (:require [name.config :as config])) 

However, this leads to a compilation error from Garden.

Called: java.io.FileNotFoundException: Could not find the name / config __init.class or the name /config.clj in the classpath.

I assume that he did not even check cljc files.

I added "src/cljc" to the vector :source-paths in project.clj and :garden :builds , but I get the same error even after restarting the build processes.

I see this behavior on Clojure 1.7.0 and 1.8.0.

It is also worth noting that it works without problems in ClojureScript (with Figwheel processing the assembly). I can easily use and use the new namespace.

It seems like I should be missing out on something really simple, because no documentation around .cljc files even needs to be mentioned.

+7
clojure clojurescript
source share
2 answers

Check if you are using Clojure 1.7 or higher in project.clj . This error message is:

Called: java.io.FileNotFoundException: Could not find the name / config __init.class or the name /config.clj in the classpath.

indicates that you are using Clojure 1.6 or lower, since those versions of Clojure only know .class or .clj .

+5
source share

I have the same error when I moved a file from .clj to .cljc to my project. I did lein clean , but it did not affect. In the end, I renamed the module namespace and fixed it.

(I assume that there was some cache of compiled modules, and it was referencing a module that no longer existed, but cljc was not recompiled because the module of this name was still cached.)

When I renamed the module namespace, it worked without any code changes.

0
source share

All Articles