Skip to content

chore: clippy disallows std::env access outside the config module - #217

Draft
ecalifornica wants to merge 1 commit into
robert/config-test-envfrom
robert/config-env-lint
Draft

chore: clippy disallows std::env access outside the config module#217
ecalifornica wants to merge 1 commit into
robert/config-test-envfrom
robert/config-env-lint

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Part of #187; with the two PRs below it, closes #187. No user-visible changes.

What

  • clippy.toml adds a disallowed-methods rule for std::env::var, var_os, vars, vars_os, set_var, and remove_var. Readers take the value as a parameter; tests construct values instead of mutating the environment.
  • The clippy quality gate (scripts/quality_gates.sh, the gate CI runs) adds --all-targets, so the rule covers unit tests, integration tests, examples, and build scripts. Without it, clippy skips test and example code, which is where the env-mutating machinery lived.
  • Five sites carry #[expect(clippy::disallowed_methods)] with a reason:
    • path-cli config::search_path: the config module is the one place that reads the environment.
    • path-cli fuzzy::which: the fzf probe keeps its own read until the search-path question on the bottom PR of this stack is decided. A follow-up PR removes this exception.
    • pathbase-client/build.rs: cargo passes OUT_DIR to a build script only through the environment.
    • toolpath-cursor's dump_fixture example and real_session_sanity test: both read the developer's real Cursor store on purpose.
  • #[expect] rather than #[allow]: an exception that stops firing becomes a warning itself, so stale exceptions fail the gate.

Verified

  • Red-first: an unannotated std::env::var call in src code and in #[cfg(test)] code each fail the gate with the configured reason. The test-code probe passes without --all-targets, so the gate change is load-bearing.
  • cargo clippy --workspace --all-targets -- -D warnings is clean on this branch. A stale build cache can mask a new clippy.toml locally; cargo clean -p <crate> refreshes it. Fresh CI checkouts are unaffected.

@ecalifornica ecalifornica changed the title robert/config env lint chore: clippy disallows std::env access outside the config module Aug 14, 2026
@ecalifornica
ecalifornica force-pushed the robert/config-env-lint branch from 9b1b2d8 to d4b9959 Compare August 14, 2026 19:49
@github-actions

Copy link
Copy Markdown

🔍 Preview deployed: https://c1ec4150.toolpath.pages.dev

clippy.toml adds a disallowed-methods rule for std::env::var,
var_os, vars, vars_os, set_var, and remove_var. Readers must take
the value as a parameter. Tests construct values instead of
mutating the environment.

The clippy quality gate runs with --all-targets, so the rule covers
unit tests, integration tests, examples, and build scripts.

Five sites carry an #[expect] with a reason:

- crates/path-cli/src/config.rs search_path: the config module is
  the one place that reads the environment.
- crates/path-cli/src/fuzzy.rs which: the fzf probe keeps its own
  read until the search path's owner is decided in review.
- crates/pathbase-client/build.rs: cargo passes OUT_DIR to a build
  script only through the environment.
- crates/toolpath-cursor/examples/dump_fixture.rs and
  crates/toolpath-cursor/tests/real_session_sanity.rs: both read the
  developer's real Cursor store, so both must locate the real home
  directory.
@ecalifornica
ecalifornica force-pushed the robert/config-env-lint branch from d4b9959 to 52e0466 Compare August 18, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the test env machinery. Add a lint.

1 participant