Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when attempting to change hard-coded eval-in-leiningen fields #769

Open
charleslparker opened this issue Sep 6, 2012 · 9 comments
Open

Comments

@charleslparker
Copy link
Contributor

I don't have much experience with Leiningen, but this looks awfully strange (note that I have lein2 as both 2.x and 1.7.x are running on my system).

Charless-MacBook-Air:featurize charleslparker$ lein2 clean
Charless-MacBook-Air:featurize charleslparker$ lein2 compile
Compiling 1 source files to /Users/charleslparker/gitrepos/featurize/target/classes
Compiling featurize.main
Compilation failed: java.io.IOException: No such file or directory, compiling:(featurize/main.clj:7)
Charless-MacBook-Air:featurize charleslparker$ lein2 clean
Charless-MacBook-Air:featurize charleslparker$ lein2 trampoline compile
Warning: trampoline has no effect with :eval-in-leiningen.
Compiling 1 source files to /Users/charleslparker/gitrepos/featurize/target/classes
Compiling featurize.main
Charless-MacBook-Air:featurize charleslparker$ 

Clearly trampoline does have some effect. The same thing happens with lein2 test; I can run tests when using trampoline, but the build fails when I don't.

My project.clj:

(defproject featurize "0.1.0-SNAPSHOT"
  :source-paths ["src/clj"]
  :resource-paths ["res"]
  :java-source-paths ["src/java"]
  :main featurize.main
  :eval-in-leiningen true
  :profiles {:dev
             {:dependencies [[swank-clojure "1.4.2"]]}}
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.apache.lucene/lucene-analyzers "3.6.1"]
                 [org.clojure/tools.cli "0.2.2"]
                 [com.taoensso/timbre "0.8.0"]])
@technomancy
Copy link
Owner

Yeah, in this case the problem is that you can't change :source-paths while using :eval-in-leiningen. The message should be clearer though.

@charleslparker
Copy link
Contributor Author

But using trampoline to "bounce around" that restriction is a legal move, or is it some sort of hole that's going to be closed?

@technomancy
Copy link
Owner

I'd say it's a loophole. The point of trampoline is to avoid the creation of a subprocess, which is something you already get by definition with :eval-in-leiningen. There are certain restrictions with :eval-in-leiningen that we can't work around due to bootstrapping difficulties; having things behave differently in trampoline on purpose is not something I want to support; it's undefined behaviour. Why are you setting :eval-in-leiningen to begin with?

@charleslparker
Copy link
Contributor Author

I'd say it's a loophole.

I figured it was.

Why are you setting :eval-in-leiningen to begin with?

I've got project-specific tasks defined in src/leiningen.

On a related note, I've got a more minimal example of the problem:

1.) Start a new project with lein new tproj.

2.) Modify project.clj so it looks like this:

(defproject tproj "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]]
  :eval-in-leiningen true
  :aot [tproj.core]
  :main tproj.core)

3.) and src/tproj/core.clj:

(ns tproj.core
  (:gen-class :main true))

(defn -main [& args]
  (println "Hello, Main!"))

And you get the following behavior:

Charless-MacBook-Air:tproj charleslparker$ lein2 clean
Charless-MacBook-Air:tproj charleslparker$ lein2 run
Compiling tproj.core
Compilation failed: java.io.IOException: No such file or directory, compiling:(tproj/core.clj:1)
Charless-MacBook-Air:tproj charleslparker$ lein2 clean
Charless-MacBook-Air:tproj charleslparker$ lein2 trampoline run
Warning: trampoline has no effect with :eval-in-leiningen.
Compiling tproj.core
Compiling tproj.core
Hello, Main!
Charless-MacBook-Air:tproj charleslparker$ 

Taking out :eval-in-leiningen makes things behave again. Also, taking out :aot and :main allows compilation and testing. If one isn't supposed to use eval-in-leiningen to create project-specific tasks, I'll volunteer to add a comment on some Stack Overflow responses :)

Thanks for all your hard work on this, by the way. It's a really nice thing.

@technomancy
Copy link
Owner

Charles Parker notifications@github.com writes:

Why are you setting :eval-in-leiningen to begin with?

I've got project-specific tasks defined in src/leiningen.

OK, that's handled much better by this:

$ mkdir tasks
$ mv src/leiningen tasks/
$ echo tasks > .lein-classpath

On a related note, I've got a more minimal example of the problem:

[...]

Charless-MacBook-Air:tproj charleslparker$ lein2 clean
Charless-MacBook-Air:tproj charleslparker$ lein2 run
Compiling tproj.core
Compilation failed: java.io.IOException: No such file or directory, compiling:(tproj/core.clj:1)

This might be pointing to a different problem where the project's default
:compile-path needs to be changed if it's using :eval-in-leiningen.

@charleslparker
Copy link
Contributor Author

OK, that's handled much better by this:

Indeed it is - I've made a few posts so it doesn't get forgotten. I'd also be happy to do a little PR to update PLUGINS.md with this information if you think it would be useful. I think it's a pretty common case and there's not much on the innertubes about it (as it is in 2.x).

@trptcolin
Copy link
Collaborator

@charleslparker +1 on a PR or wiki edit to update lein project documentation to point this out. This is great stuff - somehow I didn't know about it either.

@technomancy
Copy link
Owner

Yeah, there's a brief mention in PLUGINS.md, but I agree it's not easy to find. Happy to have that improved.

@technomancy
Copy link
Owner

Leaving this open with a different name so we could get warnings about what can't be changed with :eval-in-project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants