`netlify env:import .env` not uploading Environment Variables into the linked Netlify Project

My netlify site is: commonguide.netlify.app

I’ve run netlify env:import .env per Get started with Netlify CLI | Netlify Docs, it takes a moment to run, but then seems to have done nothing (full log of debug output below).

  1. I’m running what I think is the latest version of netlify-cli (13.3.1) from my command line.
  2. Locally I have a .env file that is ignored per .gitignore.
  3. The project is linked to the correct repo, used netlify link and double checked it too.

How I can tell it’s not working:

  1. My deploy is still reporting the same error that implies that the environment variable is undefined.
  2. Site Settings > Environment Variables remains empty
  3. Running netlify env:list reports “No environment variables set for site commonguide in the dev context”

Why is the contents of my .env file not uploading into the Environment Variables in the Netlify project?

Contents of .env

SITE_NAME=Common Guide
REPO_NAME=commonguide
REPO_URL=GitHub - CommonGuide/commonguide
EDIT_URI=edit/main/docs/
THEME_NAME=material

Log from running ‘netlify env:import .env --debug’:

branch: main
buildDir: /Users/me/projects/commonguide
configPath: /Users/me/projects/commonguide/netlify.toml
context: dev
env:

  • DEPLOY_ID
  • BUILD_ID
  • REPOSITORY_URL
  • NETLIFY_LOCAL
  • HEAD
  • COMMIT_REF
  • CACHED_COMMIT_REF
  • PULL_REQUEST
  • LANG
  • LANGUAGE
  • LC_ALL
  • GATSBY_TELEMETRY_DISABLED
  • NEXT_TELEMETRY_DISABLED

❯ Resolved config
build:
command: mkdocs build
commandOrigin: config
publish: /Users/me/projects/commonguide/site
publishOrigin: config

Hi @richie :wave:t6:,

Are you running this in your root directory where the .env is located? Were there any errors in the terminal output?

I’ve included the terminal output in the question.
Yeah no errors get reported, hence why initially I thought it was an error in how I was doing it.

Yes i was running it in the root directory where the .env file is.

I’ve worked out the issue.
My .env file included:
SITE_NAME=Common Guide

When I go to import this manually via the admin interface, it generates an error:


Sure enough, by removing an attempt to set SITE_NAME in my .env it then works.

Based on this, I’d now like to report a explicit bug.

Running netlify env:import .env silently fails when a reserved environment variable is included in the .env file.

To correct the bug:
The command should return an explicit fail and provide the same warning that is shown in the visual interfacet.

Something like this:

$ netlify env:import .env
Import failed. Reason: SITE_NAME is a reserved environment variable. Remove reserved variables from file and retry.

Please raise a ticket.

Please raise a ticket.

Running netlify env:import .env silently fails when a reserved environment variable is included in the .env file.

To correct the bug:
The command should return an explicit fail and provide the same warning that is shown in the visual interface. Eg. Import failed. Reason: SITE_NAME is a reserved environment variable. Remove reserved variables from file and retry.

@richie thanks for the write up on it, it seems to be a bug indeed. Can you please open it on our public cli repo:

Thanks!

Github issue raised as requested:

Thank you for raising this issue. I hope this is resolved soon.