lein run causes compilation #145

kototama opened this Issue Dec 10, 2010 · 6 comments

2 participants


I'm currently using leiningen 1.3.0 and the run plugin. The semantic of the leiningen 1.4.0 run are differents and more restrictive: we can't pass a second argument to run an arbitrary Clojure script (this is very usefull when you have a lot of independent "tests" programs in the same project). It's a problem for me since I can not used anymore the old run plugin.

After specifying a :main file we can use the run command, but it causes a compilation (the old run plugin does not compile anything). This is also a problem since a compilation takes way too long for our project, we would like to "lein run" without requiring a compilation and with the checkouts linked directories available.


this is very useful when you have a lot of independent "tests" programs in the same project

If you have tests, put them in the test/ directory. Then you can use them with lein run.

After specifying a :main file we can use the run command, but it causes a compilation

With 1.4.0 you can set a list of :aliases mapping keywords to namespaces; this will not trigger AOT. If it's desirable I can add a :skip-main-aot flag to Leiningen 1.4.1; would that be better than using :aliases?


They are not tests as such but examples/demo programs. While :run-aliases avoid AOT it makes things more complex : I have to define one alias for each of theses examples and everytime I add one.

It seems also that it requires a file with a -main method?

$ lein run :runme
"hello world"
Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5415)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$null_opt.invoke(main.clj:279)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:422)
at clojure.lang.Var.invoke(Var.java:369)
at clojure.lang.AFn.applyToHelper(AFn.java:165)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at user$eval13.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 12 more

What about having the semantic of the old run plugin:
"lein run [ [ ...]]
Calls namespace/function in a new process; function defaults to -main.

lein run [ ...]
Runs the .clj file using clojure.main."

Thus aliases could be avoided and the system kept flexible. What do you think about it?


Leiningen is definitely not going to load a file without running its -main function, because that would encourage projects that put side-effects at the top-level, making reloading unsafe.

I'm on the fence about running files that are not on the classpath. I'd rather have projects keep all their code on the classpath, otherwise it's really a second-class citizen as far as being part of the project. Perhaps we could add an examples/ directory to the classpath if it exists. I can't think of a good justification for running files off the classpath, but if someone has one, I'd be happy to hear it.


Add a test for :skip-aot on :main. Closed by c5c7603.


I can understand your view of putting side effects at the top-level and maybe we should refactor our examples to have a -main function (but without :gen-class since we don't need that).

The runned example programs are located in the classpath, in src/. So you are probably right and maybe the skip-aot option is enough.


Great; I've gone ahead and implemented skip-aot on main; you can see how it works in test_projects/tricky-name/project.clj.

@pjstadig pjstadig pushed a commit to pjstadig/leiningen that referenced this issue May 12, 2011
@technomancy Add a test for :skip-aot on :main. Fixes #145. c5c7603
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment