Open BorisTB opened 1 year ago
Hey @BorisTB we recently changed the way we handled env's with tasks. Can you try it again with the most recent version of Nx (v17.0.1)?
Hey, tried it with v17.0.2 and issue's still there. It's here in the source code
This is affecting my usage of nested .env variables with vite. However I seem to be able to workaround the problem for the serve
target if I don't run nx from the repo root. e.g.
cd apps/cloud-ui
nx serve cloud-ui # works: the value of NX_BAR is 'foo'
cd ../..
nx serve cloud-ui # broken: the value of NX_BAR is '$NX_FOO'
However this does not work with the build
target:
cd apps/cloud-ui
nx build cloud-ui --verbose
> nx run cloud-ui:build:production
> NX The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:372:5)
at validateString (node:internal/validators:120:11)
at join (node:path:1172:7)
at validateTypes (/home/tbj/git/cyto/node_modules/.pnpm/@nx+vite@17.0.2_@swc+core@1.3.91_@types+node@18.14.2_nx@17.0.2_typescript@5.1.6_vite@4.3.9_vitest@0.32.4/node_modules/@nx/vite/src/utils/executor-utils.js:22:38)
at viteBuildExecutor (/home/tbj/git/cyto/node_modules/.pnpm/@nx+vite@17.0.2_@swc+core@1.3.91_@types+node@18.14.2_nx@17.0.2_typescript@5.1.6_vite@4.3.9_vitest@0.32.4/node_modules/@nx/vite/src/executors/build/build.impl.js:34:48)
at async getLastValueFromAsyncIterableIterator (/home/tbj/git/cyto/node_modules/.pnpm/nx@17.0.2_@swc+core@1.3.91/node_modules/nx/src/utils/async-iterator.js:13:19)
at async iteratorToProcessStatusCode (/home/tbj/git/cyto/node_modules/.pnpm/nx@17.0.2_@swc+core@1.3.91/node_modules/nx/src/command-line/run/run.js:41:29)
at async handleErrors (/home/tbj/git/cyto/node_modules/.pnpm/nx@17.0.2_@swc+core@1.3.91/node_modules/nx/src/utils/params.js:9:16)
at async process.<anonymous> (/home/tbj/git/cyto/node_modules/.pnpm/nx@17.0.2_@swc+core@1.3.91/node_modules/nx/bin/run-executor.js:59:28)
This is with Nx 17.0.2
The possible fix is processEnv: { …environmentVariables },
but idk how to write tests for it
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
Still an issue.
nx serve foo # broken: ${vars} in vite .env files do not get expanded cd apps/foo && vite serve # works
On Thu, Nov 9, 2023, 7:20 PM github-actions[bot] @.***> wrote:
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
— Reply to this email directly, view it on GitHub https://github.com/nrwl/nx/issues/19437#issuecomment-1804879865, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5XEHM4TT7NP3ATYAY3JDYDVXL5AVCNFSM6AAAAAA5SQIWX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUHA3TSOBWGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I confirm this is still an issue. Expanded env variables can't be used.
yikes, there should probably be a test for this. is everything okay at nx, this is beyond low hanging fruit. this is fruit that's already dropped to the ground and slowly rotting away
Are there any updates on this issue? We're running into the same thing right now, we can't use env var expansion in any of our tasks.
Current Behavior
Task env variables that are expanded are immediately overwritten by original values. So expand doesn't work for tasks.
Expected Behavior
task runner will expand env variables
GitHub Repo
No response
Steps to Reproduce
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response