Clojure *compile-path* not set properly

342 views
Skip to first unread message

MC Andre

unread,
Mar 6, 2011, 8:32:10 PM3/6/11
to Clojure
Clojure can't find and compile my scripts unless I augment the compile
path.

Specs:

Clojure 1.2.0
MacPorts 1.9.2
Mac OS X 10.6.6

$ cat hello.clj
#!/usr/bin/env clj

(ns hello)
(println "Hello World!")
$ clj hello.clj
Hello World!
$ clj
Clojure 1.2.0
user=> (compile 'hello)
Hello World!
java.io.IOException: No such file or directory (NO_SOURCE_FILE:0)
user=> *compile-path*
"classes"
user=> (set! *compile-path* (str *compile-path* ":."))
"classes:."
user=> (compile 'hello)
Hello World!
hello

Armando Blancas

unread,
Mar 7, 2011, 5:50:19 PM3/7/11
to Clojure
That's the default. You'd usually use the sys env clojure.compile.path
for the repl (on windows):

>java -Dclojure.compile.path=".;src;classes" -cp clojure.jar clojure.main
Clojure 1.2.0
user=> *compile-path*
".;src;classes"

Stuart Sierra

unread,
Mar 7, 2011, 9:27:35 PM3/7/11
to clo...@googlegroups.com
The Java system property "clojure.compile.path" is the directory where the Clojure compiler will write out .class files.  It should be one directory name, not a list.  

When Clojure starts, it sets the Var *compile-path* to the value of the Java system property. The default is the directory named "classes".

Whatever value you set for clojure.compile.path, that directory must also be on the Java classpath, set with the -cp command-line option to java.

So, if you want to compile Clojure namespaces rooted at the current directory, you would run:

    java -Dclojure.compile.path=. -cp .:clojure.jar clojure.main

-Stuart Sierra

Armando Blancas

unread,
Mar 7, 2011, 10:21:33 PM3/7/11
to Clojure
Oops -- I got the class and compile paths mixed up. But I wonder why
that worked in the OP.
Reply all
Reply to author
Forward
0 new messages