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

[Beta] Dotenv expand is failing the build - consider reverting processing process. env #11197

Closed
7 tasks done
AlexandreBonaventure opened this issue Dec 5, 2022 · 7 comments · Fixed by #11213
Closed
7 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Milestone

Comments

@AlexandreBonaventure
Copy link
Contributor

Describe the bug

Hi,
One of the breaking changes in vite late alpha is preventing us to run the beta:
d5fe92c

Parsing / expanding with dotenv process.env variable is highly disruptive and certainly can lead to unexpected behaviour. Here we are testing Warp terminal, it is injecting this WARP_PS1 containing $. I can see how this could randomly bite other users and some side effects might be hard to debug (if it actually expand some variables from process.env)

Capture d’écran, le 2022-12-05 à 10 06 45

Please consider reverting this change, this issue was already reported in the past but now that process.env is parsed we don't have any control on these vars for escaping the $ so the workaround cannot be applied see #6858 (comment)

Reproduction

Not relevant

Steps to reproduce

No response

System Info

Not relevant

Used Package Manager

npm

Logs

No response

Validations

@AlexandreBonaventure AlexandreBonaventure changed the title [Beta] Dotenv expand is failing the build - consider reverting processing » [Beta] Dotenv expand is failing the build - consider reverting processing process. env Dec 5, 2022
@bluwy
Copy link
Member

bluwy commented Dec 5, 2022

process.env shouldn't be expanded. Expand should only work in .env files, so this is a bug to me. It seems to happen because of

parsed: {
...(process.env as any),
...parsed,
},

Seems like we might need to fork dotenv-expand, or have expand not use process.env until a minor 🤔 cc @Dunqing @sapphi-red

@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Dec 5, 2022
@Dunqing
Copy link
Contributor

Dunqing commented Dec 6, 2022

I think we still need expand process.env, which is intentional and allows us to use ci's environment variables in env files, which is very useful

@Dunqing
Copy link
Contributor

Dunqing commented Dec 6, 2022

Seems like we might need to fork dotenv-expand

I prefer to workaround the bug in this way

@sapphi-red sapphi-red added this to the 4.0 milestone Dec 6, 2022
@sapphi-red
Copy link
Member

Maybe we could escape process.env before passing to dotenv-expand? That way I think we could avoid forking.

@bluwy
Copy link
Member

bluwy commented Dec 6, 2022

I think we still need expand process.env, which is intentional and allows us to use ci's environment variables in env files, which is very useful

Yeah we should expand .env using process.env, but we shouldn't expand the process.env itself.

Maybe we could escape process.env before passing to dotenv-expand? That way I think we could avoid forking.

I think that brings perf implications compared to forking it. Maybe looping in @motdotla if this could be implemented upstream? Summary so far is that we want to read process.env when expanding, but we don't want to write back to process.env (skips this code).

@patak-dev
Copy link
Member

Maybe we can have a patch in the vite monorepo instead of forking until this is implemented upstream?

@Dunqing
Copy link
Contributor

Dunqing commented Dec 6, 2022

It is worth mentioning that If we fork dotenv-expand, we can also fix TypeError: Cannot read properties of undefined (reading 'split') and remove #11141 .

@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants