Skip to content

fix: restore application env exactly after evaluating project config - #400

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
neilberkman:fix/restore-application-env-exactly
Sep 3, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
neilberkman:fix/restore-application-env-exactly

Conversation

@neilberkman

Copy link
Copy Markdown
Contributor

with_evaled_configs/2 evaluates the project's config/config.exs and config/<env>.exs, applies the result with Application.put_all_env/1, and afterwards restores a per-application snapshot with Application.put_all_env/1 again. put_all_env only writes the keys it is given, so any key the evaluated config introduced that was absent before stays set in the VM after the call returns.

This shows up in test suites that drive an Igniter installer against fixtures configuring the library under test. Every task that touches files goes through Igniter.format/2, so after such a test the fixture's config :my_lib, MyLib.Config, ... remains under {:my_lib, MyLib.Config} for the rest of the run, and unrelated tests that read that key pass or fail depending on test order.

The restore now deletes keys that were not in the snapshot before putting the snapshot back. The regression test covers a key that did not exist before, a pre-existing key that the evaluated config assigned a different value, and an application that had no environment at all.

test/mix/tasks/igniter.install_test.exs on current main does not compile (install/1 is undefined); this change does not touch it.

with_evaled_configs/2 applies the evaluated project config with
Application.put_all_env/1 and restored a per-application snapshot with
put_all_env/1 as well. put_all_env only writes the keys it is given, so
keys that the evaluated config introduced stayed set in the VM after the
call returned. Every task that touches files goes through Igniter.format/2,
so test suites driving an installer against fixtures that configure the
library under test kept that fixture config for the rest of the run.

The restore now deletes keys absent from the snapshot before putting the
snapshot back. The regression test covers an added key, a pre-existing key
assigned a different value, and an application with no prior environment.
@zachdaniel
zachdaniel merged commit b3fd506 into ash-project:main Sep 3, 2026
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants