technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

Warning regarding missing profile printed erroneously and twice. #2773

Closed tobyclemson closed 2 years ago

tobyclemson commented 2 years ago

Initial debugging steps Before creating a report, especially around exceptions being thrown when running Leiningen, please check if the error still occurs after:

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

Additional context N/A

technomancy commented 2 years ago

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.