intellij-ideaclojureedn

File core.clj is not under a source root error in intellij


I am using IntelliJ IDEA in a Clojure project, I just started but I get the message "File core.clj is not under a source root", the project has 2 folders: .idea and src, inside src I got the core.clj file in which showing the structure of the project. This is the photo containing the structure of the project.

I have no source root, I just created the core.clj and the deps.edn file and the Deps_project.iml file, nothing else, how can I solve this? Do I need to write another file?


Solution

  • You need just two files for your project:

    In file deps.edn

    {:paths ["src"]
     :deps  {org.clojure/spec.alpha {:mvn/version "0.3.218"}}}
    

    In file src/spec_tutorial/core.clj

    (ns spec-tutorial.core
      (:require [clojure.spec.alpha :as s]))
    

    Note there is a correspondence between the Clojure namespace and the source file path, but beware that hyphens - in namespaces are translated to underscores _ in path names.