Skip to content

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

@Soviut

Description

@Soviut

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions