jcrossley3 / lein-modules

An alternative to Maven multi-module projects in Leiningen
Eclipse Public License 1.0
83 stars 17 forks source link

Should eval/sh be called without CLASSPATH? #46

Open quoll opened 3 years ago

quoll commented 3 years ago

When setting up simple modules, they each report:

WARNING: You have $CLASSPATH set, probably by accident.
It is strongly recommended to unset this before proceeding.

This is from the Leiningen script which checks if this is set. It then sets the CLASSPATH before launching the JVM. When lein-modules builds sub-modules, it does so by executing the leiningen command script in a shell via leiningen.core.eval/sh. Leiningen picks up the current environment (unless overridden by a dynamic binding) which has the CLASSPATH set in it now, hence the warnings.

I think that adding a new binding before executing the shell should solve the issue, but I wanted to ask before making a PR:

Lines 194-197

(binding [eval/*dir* (:root project)
          eval/*env* (with-meta (dissoc (into {} (System/getenv)) "CLASSPATH") {:replace true})]
  (let [exit-code (apply eval/sh (cons cmd args))]
    (when (pos? exit-code)
      (throw (ex-info "Subprocess failed" {:exit-code exit-code}))))
jcrossley3 commented 3 years ago

Sounds reasonable to me -- PR away!