Skip to content
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

.env files not loaded when CWD is not workspace root #22846

Open
1 of 4 tasks
kylebjordahl opened this issue Apr 16, 2024 · 0 comments
Open
1 of 4 tasks

.env files not loaded when CWD is not workspace root #22846

kylebjordahl opened this issue Apr 16, 2024 · 0 comments
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@kylebjordahl
Copy link

Current Behavior

When running the Nx CLI from a directory within the workspace (but not the root folder) .env files in the project directories fail to load.

Root .env files also fail to load, but it is unclear whether this is expected (are the .env files listed as 10-18 on the docs intended to be relative to the CWD or explicitly in the workspace root?)

Expected Behavior

If I have a .env file apps/my-app/.env.local and I run cd apps && nx run my-app:serve it should load the environment variables from apps/my-app/.env.local

GitHub Repo

https://github.com/kylebjordahl/nx-examples/tree/kb/env-loading-repro

Steps to Reproduce

  1. run a target which consumes an environment variable loaded from a .env file in the project root from a directory which is not the workspace root

(in the reproduction repo, see apps/env-printer/README.md)

Nx Report

# Note this is from the original repo where the issue was observed, not the reproduction

Node   : 20.12.1
OS     : linux-arm64
pnpm   : 8.15.6

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/jest           : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/cypress        : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/plugin         : 18.0.7
@nx/react          : 18.0.7
@nx/remix          : 18.0.7
@nx/storybook      : 18.0.7
@nrwl/tao          : 18.0.7
@nx/vite           : 18.0.7
@nx/web            : 18.0.7
typescript         : 5.3.3
---------------------------------------
Community plugins:
@nxlv/python : 18.0.1
---------------------------------------
Local workspace plugins:
         @rh-plugins/cdk-python
         @rh-plugins/protobuf
         @rh-plugins/python

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: core core nx functionality type: bug
Projects
None yet
Development

No branches or pull requests

3 participants