10

To start off I am not a Java programmer, so it would be helpful if your answers are not defined in terms of Java (inasmuch as that makes sense).

I have a leiningen project (specifically a web project using noir) using what seems to be a common pattern of putting your clojure source files in src/YOUR-NAMESPACE/. So far I've had success adding directories and files, and I have been using the file path as the basis for the ns (following the pattern I see in the generated code).

I added a new file that did not work, and I'm wondering why. It's path is PROJECT-ROOT/src/bayou/lib/api-helpers.clj and its namespace is (ns bayou.lib.api-helpers). The specific error I'm getting is:

java.io.FileNotFoundException: Could not locate bayou/lib/api_helpers__init.class or bayou/lib/api_helpers.clj on classpath

What are all the steps one as to take in order for clojure to recognize a namespace?

animuson
  • 53,861
  • 28
  • 137
  • 147
benekastah
  • 5,651
  • 1
  • 35
  • 50
  • After I wrote this question I also found this helpful question: http://stackoverflow.com/questions/2223190/what-are-common-conventions-for-using-namespaces-in-clojure – benekastah Nov 23 '11 at 04:16

1 Answers1

14

The problem is the hyphen in the namespace.

From the Joy of Clojure

HYPHENS/UNDERSCORES If you decide to name your namespaces with hyphens, à la my-cool-lib, then the corresponding source file must be named with underscores in place of the hyphens (my_cool_lib.clj).

Here is the underlying explanation: https://stackoverflow.com/q/4451693/32174

Community
  • 1
  • 1
Julien Chastang
  • 17,592
  • 12
  • 63
  • 89