Warning regarding missing profile printed erroneously and twice.
tobyclemson opened this issue · comments
Initial debugging steps
Before creating a report, especially around exceptions being thrown when running Leiningen, please check if the error still occurs after:
- Updating to using the latest released version of Leiningen (
lein upgrade
). - Moving your
~/.lein/profiles.clj
(if present) out of the way. This contains third-party dependencies and plugins that can cause problems inside Leiningen. - Updating any old versions of plugins in your
project.clj
, especially if the problem is with a plugin not working. Old versions of plugins like nREPL and CIDER (as well as others) can cause problems with newer versions of Leiningen. - (If you are using Java 9 or newer), updating your dependencies to their most recent versions. Recent JDK's have introduced changes which can break some Clojure libraries.
Describe the bug
When a default profile is composite with a profile added by middleware, leiningen warns that the profile added by the middleware doesn't exist. For some reason the warning is displayed twice. This warning is displayed despite the fact that the composite profile works as expected after middleware has been applied.
The specific case in which this is affecting me is when using lein-parent
which merges parts of a parent project.clj into the current project.clj. I've got a :parent-dev
profile which is composed into the current project's :dev
profile. See the reproduction repo for examples.
To Reproduce
See the minimal reproduction case at https://github.com/tobyclemson/leiningen-warning-repro
To reproduce, run lein cprint
and observe the following at the top of the output:
Warning: profile :parent-dev not found.
Warning: profile :parent-dev not found.
...
Actual behavior
Leiningen warns about a missing profile that isn't missing. This warning is output twice. Regardless, the profile is merged correctly so the warning doesn't make sense.
Running lein with-profile +dev cprint
shows that the profiles merge correctly:
Warning: profile :parent-dev not found.
Warning: profile :parent-dev not found.
{
...
:key :value,
...
:profiles {:dev [:parent-dev], :parent-dev {:key :value}},
...
}
Expected behavior
Ideally, no warnings would print since the profile does exist and the warnings seem to be the result of leiningen's own project evaluation ordering rather than a problem with configuration.
Link to sample project
https://github.com/tobyclemson/leiningen-warning-repro
Logs
N/A, described above
Environment
- Leiningen Version: 2.9.7
- Leiningen installation method: Homebrew
- JDK Version: tested on openjdk versions "1.8.0_292" and "11.0.12"
- OS: macOS 11.5
Additional context
N/A
I've fixed the double-warning problem.
I don't believe the other one is fixable, unfortunately. In order to find the :parent-dev
profile, we must load the plugins. But we can't load the plugins without resolving the default profile, which includes :dev
. You've created a sort of circular dependency here, and I believe this is just an inherent limitation of the very ideas of profiles and plugins rather than a bug which can be fixed.