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.netlify.local not overriding .env.netlify environment variables #4565

Closed
Soviut opened this issue Apr 26, 2022 · 1 comment
Closed

.env.netlify.local not overriding .env.netlify environment variables #4565

Soviut opened this issue Apr 26, 2022 · 1 comment
Labels
type: bug code to address defects in shipped code

Comments

@Soviut
Copy link

Soviut commented Apr 26, 2022

Describe the bug

I am using a configuration feature outlined in this PR #4321 to only inject specific .env files into my functions, but not my Vite environment.

My netlify.toml has the following

[dev]
  envFiles = [".env.netlify", ".env.netlify.local"]

When I run netlify dev I get the following.

image

Notice the .env.netlify.local is being ignored in favour of the .env.netlify variables, which get injected. Some .env.netlify.local variables are injected, but they have no counterpart in the .env.netlify file.

I was on "netlify-cli": "^9.13.6" and also tried it on "netlify-cli": "^10.0.0" but both seem to have this issue.

Steps to reproduce

  • create a new project
  • initialize netlify-cli
  • create .env.netlify and .env.netlify.local files
  • put SOME_VAR=prod and SOME_VAR=local in each file respectively
  • edit netlify.toml to include envFiles = [".env.netlify", ".env.netlify.local"] setting under [dev]
  • run netlify dev
  • observe the .env.netlify.local variable being ignored and the .env.netlify being injected

Configuration

[dev]
  envFiles = [".env.netlify", ".env.netlify.local"]

Environment

  System:
    OS: Linux 4.19 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz
    Memory: 43.23 GB / 50.14 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.16.0 - /mnt/c/Users/Ian/AppData/Roaming/npm/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
    Watchman: 2021.06.07.00 - /home/linuxbrew/.linuxbrew/bin/watchman
  npmPackages:
    netlify-cli: ^10.0.0 => 10.0.0 
@Soviut Soviut added the type: bug code to address defects in shipped code label Apr 26, 2022
@Soviut
Copy link
Author

Soviut commented Apr 26, 2022

I just found this line in the source

// in the user configuration, the order is highest to lowest

Apparently, I've had these backwards the whole time? I've changed my netlify.toml to read

[dev]
  envFiles = [".env.netlify.local", ".env.netlify"]

And this seems to be working.

Is there any way I can contribute documentation to update the following page and include the documentation for the envFiles config?

https://docs.netlify.com/configure-builds/file-based-configuration/

@Soviut Soviut closed this as completed May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

1 participant