Skip to content

--env-file parser overrides variables with commented out values #52084

Description

@egorFiNE

Version

v21.7.1

Platform

Darwin gray.local 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:45:49 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6020 arm64

Subsystem

env parser

What steps will reproduce the bug?

Create .env:

VAR=first

# SOMETHING=else
# VAR=second

Run the testcase:

node --env-file=.env -e 'console.log(process.env.VAR)'

The output is second instead of first.

Adding a non-commented variable after # SOMETHING makes the parser work correctly.

How often does it reproduce? Is there a required condition?

100% reproduction

What is the expected behavior? Why is that the expected behavior?

Commented-out line of .env is ignored.

What do you see instead?

Commented-out part is parsed and the variable value is overwritten.

Additional information

env parser works correctly in 21.6.2, emitting first in console.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.dotenvIssues and PRs related to .env file parsing.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions