Navigation Menu

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

fix: prevent loading env outside of root #6995

Merged
merged 3 commits into from Mar 3, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Feb 19, 2022

Description

Fixes #6933
Fixes #5712

Loading env files will only load from the envDir only, anything above the directory is not checked.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Shinigami92
Shinigami92 previously approved these changes Feb 19, 2022
@Niputi
Copy link
Contributor

Niputi commented Feb 19, 2022

is the new option really needed? it looks like a case which was not accounted for in implementation.
shouldn't the envDir function give the needed functionality for monorepo users and non-monorepo users?

@bluwy
Copy link
Member Author

bluwy commented Feb 19, 2022

Yeah I don't think it's needed too. We could remove it and disclose as a "bug fix", but it feels like it could be a breaking change so I played it safe here. Definitely open for discussion though.

@bluwy
Copy link
Member Author

bluwy commented Feb 19, 2022

Been thinking about it and I think it makes sense to just remove the option. I don't see a usecase where someone intend to load .env files above the envDir. Will push another commit.

@patak-dev patak-dev added this to the 2.9 milestone Feb 19, 2022
@patak-dev
Copy link
Member

To play safe, let's merge this one in the 2.9 beta period (I think we should start it in a week from now).

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label Feb 19, 2022
@ydcjeff
Copy link
Contributor

ydcjeff commented Feb 19, 2022

Should we add a note to the docs?
https://vitejs.dev/config/#envdir

@bluwy
Copy link
Member Author

bluwy commented Feb 20, 2022

I think the docs are fine right now with "The directory from which .env files are loaded". The behaviour which it loads .env files above the envDir sounds like a bug, as the docs didn't imply that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't look up for env files beyond the project root .env files from the parent directory are loaded
5 participants