Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

unable to get ns docstring if :main is set in project.clj (meta doc) #575

Closed
uvtc opened this Issue · 2 comments

2 participants

@uvtc

This is using lein 2.0.0-preview3.

If I create a new project (lein new foob) and --- touching nothing else --- add a namespace docstring to core.clj, making it look like this:

(ns foob.core
  "docstring for namespace")

then start a repl (lein repl), and do this:

user=> (require 'foob.core)
nil
user=> (meta (the-ns 'foob.core))
{:doc "docstring for namespace"}

You can see I get that docstring.

(Side issue: I can't get the docstring in the usual way,

user=> (doc foob.core)
ClassNotFoundException foob.core  java.net.URLClassLoader$1.run (URLClassLoader.java:217)

but that may be related to http://dev.clojure.org/jira/browse/CLJ-902)

Now, if I go and add ":main foob.core" to my project.clj, then start the repl again:

foob.core=> (meta (the-ns 'foob.core))
nil
foob.core=> (require 'foob.core)
nil
foob.core=> (meta (the-ns 'foob.core))
nil

That metadata appears to be missing.

If I now go back and remove the ":main foob.core" from project.clj (to get back to where I was), and restart the repl, I can't get that doc metadata back again. (!)

I get the same behaviour if I start over, but first change 1.3.0 to 1.4.0 in project.clj.

@uvtc

BTW, thanks to weavejester on irc for helping identify the issue(s)!

@technomancy
Owner

This is actually a bug in Clojure.

$ lein compile :all
java -cp `lein classpath` clojure.main -e "(prn (meta (the-ns (doto (quote foob.core) require))))"
nil

The problem is that AOT causes namespaces to lose their metadata: http://dev.clojure.org/jira/browse/CLJ-130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.