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

dotenv loaded unexpectedly when useNx: true #3371

Closed
wyardley opened this issue Oct 14, 2022 · 6 comments · Fixed by #3375
Closed

dotenv loaded unexpectedly when useNx: true #3371

wyardley opened this issue Oct 14, 2022 · 6 comments · Fixed by #3375

Comments

@wyardley
Copy link

wyardley commented Oct 14, 2022

So with Lerna 5.6 with useNX: true or Lerna 6, we're seeing a few test cases fail. They all seem to be failing because running the test target with nx enabled seems to be automagically loading an existing .env file in the directory where the tests run

I'm starting to think this behavior is from nx itself, maybe because of this:

https://github.com/nrwl/nx/blob/a66a549e4bb2bca1c63add7ed40396228c3cbcbb/packages/nx/src/tasks-runner/forked-process-task-runner.ts#L278-L279

Is there a way to disable this behavior? It seems a little overly magical, and is arguably an undocumented breaking change.

@JamesHenry
Copy link
Member

Thanks for reporting this @wyardley I have removed the discussion to keep things focused here.

We will update the release notes for v6 to highlight this change in default behaviour, and also give you a way to disable the automatic .env loading given that's desirable for your setup.

That flag will go out today and I will close this issue once it's ready.

@wyardley
Copy link
Author

Awesome. Thanks!

@JamesHenry
Copy link
Member

6.0.1 is now available which allows you to set --load-env-files=false on lerna run

@wyardley
Copy link
Author

thanks so much for the quick response + fix @JamesHenry! 💯
Really appreciated

Is there any way to set options to nx in config, or is using the flag the only way to trigger this when using nx indirectly via lerna in this way?

@JamesHenry
Copy link
Member

JamesHenry commented Oct 14, 2022

@wyardley in your lerna.json you can specify the flag for the lerna run command:

lerna.json

{
  "command": {
    "run": {
      "loadEnvFiles": false
    }
  }
}

@wyardley
Copy link
Author

Awesome. Thanks again; confirming that looks great

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 a pull request may close this issue.

2 participants