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

Custom dotEnv parser doesn't support export prefix #6629

Closed
staticshock opened this issue Dec 18, 2023 · 1 comment · Fixed by #6630
Closed

Custom dotEnv parser doesn't support export prefix #6629

staticshock opened this issue Dec 18, 2023 · 1 comment · Fixed by #6630

Comments

@staticshock
Copy link

staticshock commented Dec 18, 2023

[REQUIRED] Environment info

firebase-tools: 13.0.1

Platform: macOS

[REQUIRED] Test case

firebase init hosting
echo 'export X=y' > ./hosting/.env.test
firebase deploy

[REQUIRED] Steps to reproduce

Create a firebase project with Next.js hosting. Use export in .env, then try to deploy via firebase deploy.

It's not totally clear to me if having a "test" alias for the firebase project is relevant to .env.test getting picked up, but I'll mention it in case it is.

[REQUIRED] Expected behavior

Firebase successfully deploys, either ignoring .env.test, or at least parsing it without crashing.

[REQUIRED] Actual behavior

Firebase complains that export is not valid syntax, which is incorrect. Basically every other dotenv parser implementation supports each line being prefixed by the word export, which allows users to source that file in their shell of choice without modification during local testing.

Actual output looks like this:

=== Deploying to 'my-project-4867'...

i  deploying functions, hosting
i  functions: preparing codebase firebase-frameworks-my-project-4867 for deployment
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled
i  functions: Loading and analyzing source code for codebase firebase-frameworks-my-project-4867 to determine what to deploy
Serving at port 8221

Error: Failed to load environment variables from .env.test.:
- FirebaseError Invalid dotenv file, error on lines: export X=y

Link to relevant parser code: https://github.com/firebase/firebase-tools/blob/master/src/functions/env.ts#L114-L149

@aalej
Copy link
Contributor

aalej commented Dec 19, 2023

Hi @staticshock, thanks for the detailed report and for providing relevant code. I was able to reproduce this. I’ll mark this as reproducible and notify our engineering team so they can take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants