Skip to content

fix(process): share Node dotenv parsing for loadEnvFile#3437

Merged
proggeramlug merged 8 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-dotenv-parser-loadenv
May 31, 2026
Merged

fix(process): share Node dotenv parsing for loadEnvFile#3437
proggeramlug merged 8 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-dotenv-parser-loadenv

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

  • shares the Node-compatible dotenv parser behind util.parseEnv with process.loadEnvFile
  • matches Node dotenv cases for export prefixes, inline # comments, multiline quoted/backtick values, duplicate keys, and unterminated quotes
  • updates process.loadEnvFile path handling for omitted/undefined/null defaults, strings, Buffers, file URLs, non-file URL errors, and invalid path argument errors
  • expands parity coverage for both util.parseEnv and process.loadEnvFile

Batching rationale

These issues share the same behavioral surface: process.loadEnvFile should parse .env contents using the same Node dotenv rules exposed by util.parseEnv, and path validation needed to pass the raw JS value through lowering/codegen to runtime. Keeping them together avoids landing parser behavior that the process loader cannot yet use.

Tests

  • RUSTC_WRAPPER= cargo test -p perry-runtime util_parse_env
  • RUSTC_WRAPPER= cargo check -p perry-runtime -p perry-hir -p perry-codegen -p perry
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh
  • jq empty test-parity/known_failures.json
  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module util --filter parse-env
  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module process/methods --filter load-env-file
  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module process/methods
  • PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module util (68 pass, 1 unrelated existing node-suite/util/get-system-error output mismatch)

Non-goals

  • does not implement npm dotenv package behavior or dotenv/config wrapper changes
  • does not broaden process.env storage semantics beyond loaded values
  • does not change other fs path-like URL validation

Closes #3423. Closes #2985. Closes #3045.

@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Refreshed this branch for the latest mainline changes.

  • Merged current origin/main, including the util/sys manifest mirror fix that was failing cargo-test.
  • Applied the ReflectIsExtensible stable-hash tag correction required while current mainline still has the duplicate tag.
  • Regenerated the API manifest docs; they were already current after the merge.
  • Local checks passed: CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-api-manifest sys_alias_mirrors_util_manifest, CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-hir stable_hash::tests::expr_variant_stable_hash_tags_are_unique, CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-runtime util_parse_env::tests::parses_node_compatible, cargo fmt --all -- --check, git diff --check against the branch merge-base, git diff --check, scripts/check_file_size.sh, and workflow YAML parsing.

Ralph Küpper added 5 commits May 31, 2026 10:57
# Conflicts:
#	crates/perry-hir/src/stable_hash/expr.rs
#	crates/perry-runtime/src/process.rs
#	crates/perry-runtime/src/util_parse_env.rs
# Conflicts:
#	crates/perry-codegen/src/lower_call/native_table/node_core.rs
#	crates/perry-hir/src/lower/expr_call/native_module.rs
#	crates/perry-runtime/src/process.rs
#	test-parity/node-suite/process/methods/load-env-file.ts
@proggeramlug proggeramlug merged commit f7099ba into PerryTS:main May 31, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants