-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(core): expand env variables on load and unload #22585
Conversation
Env variables using other variables were not unloaded from the environment and further customizations were impossible in more specific env files.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 79ce059. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 6 targets
Sent with 💌 from NxCloud. |
@AgentEnder @Coly010 your feedback here will be appreciated 🙏 |
This pr is meant to replace #22585 and #20524 Env variables using other variables were not unloaded from the environment and further customizations were impossible in more specific env files. <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #23581 Co-authored-by: Mateo Tibaquira <[email protected]>
This pr is meant to replace #22585 and #20524 Env variables using other variables were not unloaded from the environment and further customizations were impossible in more specific env files. <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #23581 Co-authored-by: Mateo Tibaquira <[email protected]> (cherry picked from commit 88fd03b)
create a pr #26459 to replace this. |
Thank you @xiongemi! |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Env variables using other variables were not unloaded from the environment and further customizations were impossible in more specific env files.
Current Behavior
The unloading and re-loading of env variables in task-runner/task-env is faulty because composed variables are not unloaded because they are not expanded, just parsed and checked to be equal to the process.env value.
I'm using the
@nx-tools/nx-container
plugin to build Docker images and I'm passing some input parameters via env var like:Nx loads
.env
,.local.env
and.env.local
by default and I have the localhost configuration in one of them.But when I want to build for
production
I want to get the values of.env.production
and debugging the issue deeply I found that my var was not unloaded because it was comparing the evaluated value in process.env (INPUT_BUILD_ARGS="API_HOST=localhost\nAPI_PORT=3000"
) with the non-expanded value (INPUT_BUILD_ARGS="API_HOST=${API_HOST}\nAPI_PORT=${API_PORT}"
) so it was not unloaded.After this adjustment and the upgrade of
dotenv-expand
to not affect process.env it works successfully :)Expected Behavior
To have my composed variables expanded so they are correctly unloaded and overridden by a specific
.env*
file.