GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: return error --env-file if file is missing by arxngr · Pull Request #50588 · nodejs/node

Conversation

@arxngr

@arxngr arxngr commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

Motivated by #50536

NodeJS currently supports env file parsing. However, in cases where the file is missing, the process continues to execute. Since the env file is a crucial file, I propose that we return an error if the env file is missing. This will prevent errors in the future and allow us to detect them as early as possible.

Testing Scenario:

Given files tree:

└── test/
    ├── hello.js
    └── test.env

run: node --env-file=test.env hello.js
output: it will executed


└── test/
    ├── hello.js
    └── test.env

run: node --env-file=oops.env hello.js
output: node: oops.env not found


└── test/
    ├── hello.js
    └── test.env
    └── test1.env

run: node --env-file=test.env --env-file=test1.env hello.js
output: it will executed

└── test/
    ├── hello.js
    └── test.env
    └── test1.env

run: node --env-file=test.env --env-file=oops.env hello.js
output: node: oops.env not found

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss, Santhoshmani1, and virtuallyunknown reacted with thumbs up emoji jonatanpedersen and Carvalho-the-Dev reacted with thumbs down emoji
All reactions
  • 👍 3 reactions
  • 👎 2 reactions
@nodejs-github-bot

nodejs-github-bot commented Nov 7, 2023

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Nov 7, 2023
@arxngr
arxngr force-pushed the handling-env-file-not-found branch 2 times, most recently from 3f6ba1c to b42914a Compare November 7, 2023 07:14
@arxngr
arxngr marked this pull request as draft November 7, 2023 08:45
@arxngr
arxngr force-pushed the handling-env-file-not-found branch from b42914a to fe0265f Compare November 7, 2023 09:45
@arxngr
arxngr marked this pull request as ready for review November 7, 2023 09:49
anonrig
anonrig reviewed Nov 7, 2023
View reviewed changes
Comment thread src/node_dotenv.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/node.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/node.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@arxngr
arxngr force-pushed the handling-env-file-not-found branch 2 times, most recently from 226b7f9 to f2365e5 Compare November 8, 2023 04:26
@arxngr
arxngr requested a review from anonrig November 8, 2023 08:33
anonrig
anonrig approved these changes Nov 10, 2023
View reviewed changes
@anonrig anonrig added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 10, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 10, 2023
@nodejs-github-bot

nodejs-github-bot commented Nov 10, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55529/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Nov 11, 2023
CI Reliability 2023-11-11 nodejs/reliability#714
Open
27 tasks
@nodejs-github-bot

nodejs-github-bot commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55547/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Nov 11, 2023
View reviewed changes
@nodejs-github-bot

nodejs-github-bot commented Nov 11, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55569/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arxngr

arxngr commented Nov 11, 2023

Copy link
Copy Markdown
Contributor Author

Seems several CI have failed even already retrying, is this expected? 🤔

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arxngr

arxngr commented Nov 11, 2023

Copy link
Copy Markdown
Contributor Author

Seems several CI have failed even already retrying, is this expected? 🤔

Unit testing goes error on Windows, will check later and maybe come back with a new push

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Nov 12, 2023
CI Reliability 2023-11-12 nodejs/reliability#715
Open
18 tasks
@arxngr
arxngr force-pushed the handling-env-file-not-found branch from f2365e5 to 192d633 Compare November 12, 2023 13:35
@github-actions github-actions Bot mentioned this pull request Nov 13, 2023
CI Reliability 2023-11-13 nodejs/reliability#716
Open
24 tasks
@debadree25 debadree25 added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 13, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 13, 2023
@nodejs-github-bot

nodejs-github-bot commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55604/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

0xArdi-N
src: return error --env-file if file is not found
d3b85c1
@nodejs-github-bot

nodejs-github-bot commented Nov 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55618/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr approved these changes Nov 13, 2023
View reviewed changes
@github-actions github-actions Bot mentioned this pull request Nov 14, 2023
CI Reliability 2023-11-14 nodejs/reliability#717
Open
25 tasks
@nodejs-github-bot

nodejs-github-bot commented Nov 14, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55628/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 14, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 14, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 996d198 into nodejs:main Nov 14, 2023
@nodejs-github-bot

nodejs-github-bot commented Nov 14, 2023

Copy link
Copy Markdown
Collaborator

Landed in 996d198

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Nov 15, 2023
CI Reliability 2023-11-15 nodejs/reliability#718
Open
26 tasks
@anonrig anonrig mentioned this pull request Nov 15, 2023
Update --env-file documentation when a file cannot be found. #50734
Closed
targos pushed a commit that referenced this pull request Nov 23, 2023
@arxngr @targos
src: return error --env-file if file is not found
0d3aa72
PR-URL: #50588
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Nov 28, 2023
v21.3.0 proposal #50954
Merged
@mbrevda mbrevda mentioned this pull request Dec 1, 2023
Add --env-file-if-exists #50993
Closed
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
@arxngr @UlisesGascon
src: return error --env-file if file is not found
a848312
PR-URL: #50588
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@UlisesGascon UlisesGascon mentioned this pull request Dec 12, 2023
v20.11.0 proposal #51124
Merged
UlisesGascon pushed a commit that referenced this pull request Dec 19, 2023
@arxngr @UlisesGascon
src: return error --env-file if file is not found
6f46d31
PR-URL: #50588
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@jmjf

jmjf commented Jan 11, 2024

Copy link
Copy Markdown

@ardinugrxha

Is it intended that this change will break existing npm scripts and the CI processes that rely on them?

I have a test script that runs tests with --env-file=.env. The .env file is not checked in to my repo because it contains secrets.

This script worked in CI before 20.11 because CI has env variables set up in the CI environment. Now it fails.

My workaround will be to duplicate the test script without --env-file, but I'm not sure non-major releases in LTS should require workarounds.

acidoxee, sosoba, Ricki-BumbleDev, bgonp, thiagomini, BoscoDomingo, and Carvalho-the-Dev reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbrevda mbrevda mentioned this pull request Jan 12, 2024
.env file support issue tracker #49148
Open
8 tasks done
@acidoxee

acidoxee commented Jan 13, 2024

Copy link
Copy Markdown

Hi, I have the same issue as @jmjf. Some of my scripts used --env-file .env as a non-mandatory env injection mechanism, but now after upgrading to Node 20.11.0, all of those scripts break if the file isn't there (which happens mostly in CI). There are workarounds, so I'll get by, but it's quite surprising seeing such a breaking change land in a minor version without warning. This change isn't even mentioned as a notable change in the changelog, it's only listed in the commits.

#50993 seems like a nice alternative that would have been nice to ship at the same time, but it's not there yet. Also, it may have been sweeter to ship it the other way around, like adding a --strict-env-file or something (that breaks if the env file isn't there) instead of changing the current way of working of the --env-file flag in a breaking way.

sosoba, Ricki-BumbleDev, bgonp, thiagomini, jonatanpedersen, BoscoDomingo, and Carvalho-the-Dev reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Jan 13, 2024

Copy link
Copy Markdown
Member

@acidoxee This is an experimental feature. Breaking changes are meant to happen.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jmjf

jmjf commented Jan 13, 2024 via email

Copy link
Copy Markdown
Breaking changes in LTS? I guess I misunderstood LTS as being stable. Nevertheless, these cases indicate that there are cases where no env file is reasonable, so maybe this change should be reconsidered.
…
On Sat, Jan 13, 2024, 08:45 Yagiz Nizipli ***@***.***> wrote: @acidoxee <https://github.com/acidoxee> This is an experimental feature. Breaking changes are meant to happen. — Reply to this email directly, view it on GitHub <#50588 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AASIV63GFKYX4PAVZQKLSQTYOKFY7AVCNFSM6AAAAAA7AVC2P2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQGQ3DGMBYGQ> . You are receiving this because you were mentioned.Message ID: ***@***.***>
fabricionaweb, BoscoDomingo, and Carvalho-the-Dev reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Jan 13, 2024

Copy link
Copy Markdown
Member

--env-file=config has a stability index of 1.1 - Active Development. Let's take a look into the stability index (ref: https://nodejs.org/docs/latest/api/documentation.html#stability-index)

Stability: 1 - Experimental. The feature is not subject to [semantic versioning](https://semver.org/) rules. Non-backward compatible changes or removal may occur in any future release. Use of the feature is not recommended in production environments.
Experimental features are subdivided into stages:

1.0 - Early development. Experimental features at this stage are unfinished and subject to substantial change.
1.1 - Active development. Experimental features at this stage are nearing minimum viability.
1.2 - Release candidate. Experimental features at this stage are hopefully ready to become stable. No further breaking changes are anticipated but may still occur in response to user feedback. We encourage user testing and feedback so that we can know that this feature is ready to be marked as stable.
BoscoDomingo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jmjf jmjf mentioned this pull request Jan 13, 2024
Fail for missing env file in development only #51451
Closed
@acidoxee

acidoxee commented Jan 14, 2024

Copy link
Copy Markdown

@acidoxee This is an experimental feature. Breaking changes are meant to happen.

Oh, my apologies then, I was pretty sure it was considered stable already for some reason. A notable change in the changelog would still have been nice, but you're 100% right to do breaking changes if it's experimental and if that leads to a better, thoughtful API in the end 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@fabricionaweb fabricionaweb mentioned this pull request Apr 15, 2024
dep(env): change from native to dotenv package cross-seed/cross-seed#634
Closed
@BoscoDomingo

BoscoDomingo commented May 13, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hi, sorry for the noise this may cause:

Are you considering adding the optionality back? It'd be nice to see a --optional-env-file. Just now I was switching from dotenv-cli to the native loader, and having to create a duplicate script without the --env-file is not the best experience.

I can also try to do it myself, but I've 0 familiarity with Node's codebase and C++, when it might be an easy task for anyone more knowledgeable than me.

Edit: There's already a Feature Request for this, #50993, and a related issue #51451

gustavopch reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BoscoDomingo BoscoDomingo mentioned this pull request May 19, 2024
src: add --env-file-if-exists flag #53060
Merged
@anonrig anonrig mentioned this pull request May 27, 2024
src: make --env-file return warning when not found #53177
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 4, 2026
Develop Mayank9056-MM/ctf-silk-project#45
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@benjamingr benjamingr benjamingr approved these changes
@anonrig anonrig anonrig approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@arxngr @nodejs-github-bot @jmjf @acidoxee @anonrig @BoscoDomingo @jasnell @benjamingr @Trott @debadree25
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.