Skip to content

.env path is resolved relative breaking build_runner --workspace #192

@homeserve-lsaudon

Description

@homeserve-lsaudon

In envied_generator/lib/src/load_envs.dart, the .env is loaded CWD-relative:

final File file = File.fromUri(Uri.file(path)); // 'path' defaults to '.env'

In a Dart pub workspace, dart run build_runner build --workspace runs from the repo root, so .env resolves to <root>/.env instead of the package's .env, and generation fails:

Environment variable not found for field `apiUrl`.

(@Envied(path: '.env') doesn't help — that's already the default.)

Expected: resolve .env relative to the annotated class's package (e.g. via buildStep + AssetId), so workspace and package-local builds behave the same.

Env: envied 1.3.5, build_runner 2.15.0, Dart 3.11.5.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions