question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Describe the bug

Hi, One of the breaking changes in vite late alpha is preventing us to run the beta: https://github.com/vitejs/vite/commit/d5fe92cd2a0be2b8636e876a81a63921a808afb2

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 https://github.com/vitejs/vite/issues/6858#issuecomment-1036105762

Reproduction

Not relevant

Steps to reproduce

No response

System Info

Not relevant

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
patak-devcommented, Dec 6, 2022

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

1reaction
bluwycommented, 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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotenv-expand - npm
env file. Documentation. DotenvExpand exposes one function: expand. Expand. expand will expand your environment variables.
Read more >
Docker Compose release notes | Docker Documentation
Reverted environment variables precedence to OS over .env file. Fixes compose#9737. Updated usage strings for consistency. Resolved environment variables ...
Read more >
Environments and deployments - GitLab Docs
GitLab supports the dotenv ( .env ) file format, and expands the environment:url value with variables defined in the .env file. To use...
Read more >
pipenv Documentation - Read the Docs
Makefile, direct calls to pip and python -m venv or virtualenv. to create virtual ... Pipenv will expand environment variables (if defined) in...
Read more >
Relay
RelayThe GraphQL client that scales with you. · Built for scale · Keeps iteration quick · Automatic optimizations · Data consistency · Fetching...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found