You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from 15.7.2 (or 15.5.2) to 16.7.1 using nx migrate latest noticed that application started to fail during environment variables checks.
In my project I have a couple of env files:
apps/app/.env.production # not used at all
apps/app/.env.local # local overrides for app
.env.local # local overrides for all apps
.env # a file that contains list of all the variables required to start all the apps at once
--
So AAA_VARIABLE_NAME is resolved as JAMAL when vars are set in following order (which is expected):
AAA_VARIABLE_NAME=JAMAL in apps/app/.env.local
AAA_VARIABLE_NAME=ALICE in .env.local
AAA_VARIABLE_NAME=BOB in .env
--
AAA_VARIABLE_NAME is resolved as "" (empty string) when vars are set in following order (which is expected):
AAA_VARIABLE_NAME= in apps/app/.env.local
AAA_VARIABLE_NAME=ALICE in .env.local
AAA_VARIABLE_NAME=BOB in .env
--
AAA_VARIABLE_NAME is resolved as "ALICE" when vars are set in following order (which is expected):
# AAA_VARIABLE_NAME=JAMAL in apps/app/.env.local (disabled)
AAA_VARIABLE_NAME=ALICE in .env.local
# AAA_VARIABLE_NAME=BOB in .env (disabled)
--
But in next case value resolves to "BOB" which is NOT (!) expected here:
Current Behavior
After upgrading from
15.7.2
(or15.5.2
) to16.7.1
usingnx migrate latest
noticed that application started to fail during environment variables checks.In my project I have a couple of env files:
--
So
AAA_VARIABLE_NAME
is resolved asJAMAL
when vars are set in following order (which is expected):AAA_VARIABLE_NAME=JAMAL
inapps/app/.env.local
AAA_VARIABLE_NAME=ALICE
in.env.local
AAA_VARIABLE_NAME=BOB
in.env
--
AAA_VARIABLE_NAME
is resolved as "" (empty string) when vars are set in following order (which is expected):AAA_VARIABLE_NAME=
inapps/app/.env.local
AAA_VARIABLE_NAME=ALICE
in.env.local
AAA_VARIABLE_NAME=BOB
in.env
--
AAA_VARIABLE_NAME
is resolved as "ALICE" when vars are set in following order (which is expected):# AAA_VARIABLE_NAME=JAMAL
inapps/app/.env.local
(disabled)AAA_VARIABLE_NAME=ALICE
in.env.local
# AAA_VARIABLE_NAME=BOB
in.env
(disabled)--
But in next case value resolves to "BOB" which is NOT (!) expected here:
apps/app/.env.local
AAA_VARIABLE_NAME=ALICE
in.env.local
AAA_VARIABLE_NAME=BOB
in.env
According to https://nx.dev/recipes/tips-n-tricks/define-environment-variables value from
.env
should be ignored if value is already picked up from.env.local
orapps/app/.env.local
.Expected Behavior
AAA_VARIABLE_NAME
should be resolved toALICE
when vars are set in following order:apps/app/.env.local
AAA_VARIABLE_NAME=ALICE
in.env.local
AAA_VARIABLE_NAME=BOB
in.env
GitHub Repo
https://github.com/nullifiedtsk/nx-env-order-issue-demo-repo
Steps to Reproduce
Repo contains three branches (no master):
https://github.com/nullifiedtsk/nx-env-order-issue-demo-repo/branches/all
nestjs-plus-nx-15.5.2
-> NestJS + NX 15.5.2nestjs-plus-nx-16.7.1
-> NestJS + NX 16.7.1nx-raw-16.7.1
-> NX with typescript 16.7.1 (to ensure bug is not caused by NestJS)To reproduce the issue without this repo you will need to:
.env
file inroot
directory and putAAA_VARIABLE_NAME=BOB
inside..env.local
file inroot
directory and putAAA_VARIABLE_NAME=ALICE
inside.apps/<appname>/.env.local
and put commented#AAA_VARIABLE_NAME=JAMAL
inside.process.env
asprocess.env['AAA_VARIABLE_NAME']
Result:
16.7.1 and 15.5.2 produces different results:
Nx Report
Failure Logs
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: