简体   繁体   中英

Why am i able to require in "src", but not in "core" directory in clojure?

I have have the following project structure:

--fourth (my project folder)

---core

----core.clj

----mycore.clj

core looks like this:

(ns core.core)

(require '[core.mycore :refer [myhello2]] :verbose)
(println "hi")

mycore looks like this:

(ns core.mycore)

(defn myhello2 []

  (println "hi")
  )

If i evaluate core.clj, i get the following error: Could not locate mycore__init.class, mycore.clj or mycore.cljc on classpath.

If i do the same and i just switch the "core" directory to "src", it works. What can i do, to make it work?

I tried to put {:depths ["core"]} in deps.edn, but nothing changed.

But my deps.edn is empty: {}

Per https://clojure.org/guides/tools_build , you want to use :path , not :depths (which I've never heard of / don't know to be valid at all) to specify the locations in your source tree from which to search for items.

{
  :paths ["."]
}

...means that core.mycore will be looked for in ./core/mycore.clj instead of ./src/core/mycore.clj (as is the case with the default :paths ["src"] ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM