c.t.n.repl/refresh fails if :main is specified in project.clj

Description

If ":main" is specified in a project.clj file, c.t.n.repl/refresh function fails.

Here's the procedure to reproduce the error.

$ cat ~/.lein/profiles.clj
{:user
{:dependencies [[org.clojure/tools.namespace "0.2.7"]
[spyscope "0.1.3"]
[criterium "0.4.1"]]
:injections [(require '(clojure.tools.namespace repl find))
(try (require 'spyscope.core)
(catch RuntimeException e))]
lugins [ ]}}

$ lein new myproj
$ cd myproj
$ lein deps
$ lein repl
nREPL server started on port 52414
REPL-y 0.1.0-beta10
Clojure 1.6.0
Exit: Control+D or (exit) or (quit)
Commands: (user/help)
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
(user/sourcery function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
(user/clojuredocs name-here)
(user/clojuredocs "ns-here" "name-here")
user=> (use '[clojure.tools.namespace.repl :only (refresh)])
nil
user=> (refresh)
:reloading (myproj.core myproj.core-test)
:ok

;;; ** it works without :main in project.clj

$ vi project.clj
$ cat project.clj
(defproject myproj "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:main myproj.core
:dependencies [[org.clojure/clojure "1.6.0"]])

$ lein repl

<snip>

myproj.core=> (use '[clojure.tools.namespace.repl :only (refresh)])
nil
myproj.core=> (refresh)
:reloading (myproj.core myproj.core-test)
:error-while-loading myproj.core-test
#<CompilerException java.lang.Exception: namespace 'myproj.core' not found, compilingmyproj/core_test.clj:1:1)>

Environment

[org.clojure/tools.namespace "0.2.7"]
REPL-y 0.1.0-beta10
Clojure 1.6.0
Leiningen 2.0.0-preview10 on Java 1.8.0_20 Java HotSpot(TM) 64-Bit Server VM

Activity

Show:
Stuart Sierra
November 14, 2014, 4:44 PM

This is a known Clojure issue: reloading AOT-compiled code doesn't work.

:main in Leiningen's project.clj file triggers AOT-compilation.

Documented here: https://github.com/clojure/tools.namespace/blob/122e3d1d4fb01e4f1412d5cc7ec80dce76e8778a/README.md#warnings

import
November 14, 2014, 4:48 PM

Comment made by: keisukefukuda

Stuart,
I took some time to googling but couldn't reach the information. Sorry for submitting a known issue and thanks for your time.

Declined

Assignee

Stuart Sierra

Reporter

import

Labels

None

Approval

None

Patch

None

Priority

Major