Skip to content

fix: load hidden environment files on Windows#201

Merged
petercinibulk merged 3 commits into
mainfrom
fix/issue-200
Jul 2, 2026
Merged

fix: load hidden environment files on Windows#201
petercinibulk merged 3 commits into
mainfrom
fix/issue-200

Conversation

@techouse

@techouse techouse commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Resolve hidden environment files through the package configuration instead of Isolate.resolvePackageUri.
  • Add end-to-end coverage for both .env and .env/.env.dev.
  • Run the hidden-file regression tests on Windows and gate publish dry-runs on them.

Problem

The filesystem fallback added in #198 restored hidden environment-file support on Linux and macOS, but still failed under build-runner’s AOT process on Windows.

Although the files existed, Isolate.resolvePackageUri could not resolve the consumer package root. Envied consequently reported:

Environment variable file doesn't exist at `.env`.

Pinning envied_generator to 1.3.5 avoided the regression because that version read relative paths directly from the filesystem.

Solution

Use findPackageConfig(Directory.current) to load .dart_tool/package_config.json, locate the package identified by AssetId.package, and resolve the environment path against its declared package root.

This approach:

  • Works under build-runner AOT on Windows.
  • Preserves package-relative resolution in Dart workspaces.
  • Retains the Dart 3.9 minimum SDK through package_config 2.2.x.
  • Continues restricting filesystem fallback to hidden paths.

Testing

  • Added real build-runner fixtures for:
    • .env
    • .env/.env.dev
  • Added a focused windows-latest CI job.
  • All 171 envied_generator tests pass locally.
  • Dart analysis passes.
  • Windows, Ubuntu, and minimum Dart 3.9 GitHub Actions checks pass.

Fixes #200.

@techouse techouse added ci/cd CI/CD test Unit tests / Integration Tests labels Jul 2, 2026
@techouse techouse added bug Something isn't working dependencies Pull requests that update a dependency file labels Jul 2, 2026
@techouse techouse changed the title ci: add Windows environment file loading tests to CI workflow fix: load hidden environment files on Windows Jul 2, 2026
@techouse techouse removed ci/cd CI/CD dependencies Pull requests that update a dependency file test Unit tests / Integration Tests labels Jul 2, 2026
@techouse techouse marked this pull request as ready for review July 2, 2026 07:40
@techouse techouse requested a review from petercinibulk as a code owner July 2, 2026 07:40
@techouse techouse requested a review from Copilot July 2, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Windows-specific regression in envied_generator where hidden environment files (e.g. .env and .env/.env.dev) fail to resolve under build_runner AOT by switching resolution from Isolate.resolvePackageUri to .dart_tool/package_config.json via package_config. It also strengthens end-to-end coverage and adds a Windows CI job to prevent regressions.

Changes:

  • Resolve hidden env file paths via findPackageConfig(Directory.current) + package root lookup instead of Isolate.resolvePackageUri.
  • Expand the build_runner regression test to cover both .env and .env/.env.dev.
  • Add a Windows GitHub Actions job to run the hidden-env build_runner test and gate publish dry runs on it.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/envied_generator/lib/src/load_envs.dart Switches hidden-path filesystem fallback from Isolate.resolvePackageUri to package_config-based resolution.
packages/envied_generator/pubspec.yaml Adds package_config dependency needed for package-root resolution.
packages/envied_generator/test/hidden_directory_build_runner_test.dart Extends the e2e build_runner fixture test to validate both .env and hidden-directory env paths.
.github/workflows/test.yml Adds a Windows CI job to run the hidden env-file regression test and makes publish dry-runs depend on it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/envied_generator/lib/src/load_envs.dart
@techouse techouse added the windows MS Windows specific label Jul 2, 2026
@techouse techouse added this to the 1.3.8 milestone Jul 2, 2026
@petercinibulk petercinibulk merged commit 19f411d into main Jul 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working windows MS Windows specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Error on Build After 1.3.5

3 participants