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 var set to empty in shell does not override .env file #5833

Closed
geritol opened this issue Nov 16, 2018 · 6 comments
Closed

Env var set to empty in shell does not override .env file #5833

geritol opened this issue Nov 16, 2018 · 6 comments

Comments

@geritol
Copy link

geritol commented Nov 16, 2018

Is this a bug report?

yes

Environment

System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Binaries:
Node: 8.12.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 70.0.3538.102
Firefox: 63.0
Safari: 12.0
npmPackages:
react: ^16.6.3 => 16.6.3
react-dom: ^16.6.3 => 16.6.3
react-scripts: 2.1.1 => 2.1.1
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

(Write your steps here:)

  1. put REACT_APP_VAR=test in .env.production
  2. put console.log("VAR", process.env.REACT_APP_VAR); inApp.js
  3. run REACT_APP_VAR= npm run build
  4. serve the app (serve -s build)

Expected Behavior

The console should containt: VAR

Actual Behavior

The console contains VAR test

Reproducible Demo

https://github.com/geritol/cra-env-repro

Similar to #4002 but the issue here is that you cannot override with an empty value the vars provided in .env files.

@iansu
Copy link
Contributor

iansu commented Nov 16, 2018

Based on the discussion in #4002 it sounds like this might have something to do with dotenv-expand. Can you try removing that dependency from your project and testing again?

@geritol
Copy link
Author

geritol commented Nov 17, 2018

Removed dotenv-expand from react-scripts/config/env.js line 43 and the empty override behaves as expected!

@iansu
Copy link
Contributor

iansu commented Nov 17, 2018

Thanks for checking that. Can you create an issue with dotenv-expand and reference this issue so we can track it?

@stale
Copy link

stale bot commented Dec 17, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 17, 2018
@iansu iansu removed the stale label Dec 17, 2018
@stale
Copy link

stale bot commented Jan 18, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Jan 18, 2019
@stale
Copy link

stale bot commented Jan 26, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Jan 26, 2019
@lock lock bot locked and limited conversation to collaborators Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants