turbo
ab3259ed - fix: Normalize config dir env vars to absolute (#11146)

Commit
53 days ago
fix: Normalize config dir env vars to absolute (#11146) # Normalize Config Dir Env Vars to Absolute Paths ## Overview - This change ensures that config directory environment variables are normalised to absolute paths during process startup. It prevents “Path is not absolute” failures when these env vars are set to relative paths (common in containers or CI). The implementation is isolated to the shim. File touched: <mcfile name="mod.rs" path="/Users/vanshagarwal/turborepo/crates/turborepo-lib/src/shim/mod.rs"></mcfile> ## Affected Environment Variables - `TURBO_CONFIG_DIR_PATH` - `VERCEL_CONFIG_DIR_PATH` ## Problem - When either env var is set to a relative path (e.g., `./.config/turbo` inside a container), downstream code rejects it and surfaces a `NotAbsolute` error. This breaks builds and telemetry writes in setups that rely on relative paths. ## Root Cause - The previous logic assumed env-provided paths were absolute and did not normalize relative ones. ## Solution - On startup, the shim reads `TURBO_CONFIG_DIR_PATH` and `VERCEL_CONFIG_DIR_PATH`. - If a value is relative, it resolves it against the current working directory and canonicalizes it. - If a value is already absolute or unset, it remains unchanged. ## How It Works (Summary) 1. Read env values. 2. Detect relative paths. 3. Convert relative → absolute using the current working directory. 4. Proceed with the resolved absolute path through the rest of the system. ## Usage Examples ### Set a relative config directory locally ```bash export TURBO_CONFIG_DIR_PATH=./.config/turbo export VERCEL_CONFIG_DIR_PATH=./.config/vercel ``` - The shim will normalize these to absolute paths automatically. ### Set absolute paths (no change needed) ```bash export TURBO_CONFIG_DIR_PATH=/home/user/project/.config/turbo export VERCEL_CONFIG_DIR_PATH=/home/user/project/.config/vercel ``` ## Validation ### Local checks - `cargo fmt` — formatting is clean - `taplo format` — Cargo.toml formatting is clean - `cargo test -p turborepo-dirs` — config resolution behavior verified - `cargo test -p turborepo-telemetry` — telemetry behavior verified ### Targeted linting (modified crates only) - `cargo clippy -p turborepo-lib -p turborepo-dirs --no-deps -- -D warnings` ### Container sanity checks (example) - Set `TURBO_CONFIG_DIR_PATH` and/or `VERCEL_CONFIG_DIR_PATH` to a relative path inside the container. - Run tasks that read/write the config directory. - Observe no `NotAbsolute` errors; paths resolve to absolute. ## Scope - Only the shim implementation was changed: <mcfile name="mod.rs" path="/Users/vanshagarwal/turborepo/crates/turborepo-lib/src/shim/mod.rs"></mcfile> - No public API changes. - Backwards-compatible: unset or absolute env values are unaffected. ## Notes on Linting - Workspace-wide clippy may report unrelated warnings in other crates (e.g., an unused `Color` import in UI and an unused `ShutdownFailed` struct in process). For a minimal PR, run targeted clippy on the modified crates as shown above. If desired, follow-up cleanups can address those warnings separately.
Author
Parents
Loading