Issue Description
The intent of this report is to document a build failure pattern where cargo's incremental compilation cache references outdated struct definitions after fields are added or modified in workspace crates, causing compilation to fail with 'no field...on type' errors despite the field existing in source.
Current UX Flow (Broken)
- Developer pulls changes that modify struct fields (e.g.,
Cli in codex-tui)
- Developer runs
cargo build --bin codex
- Build fails with error:
error[E0609]: no field 'spec' on type 'codex_tui::Cli'
- Developer must manually diagnose this as stale cache issue
- Developer must manually run
cargo clean -p codex-tui
- Developer must manually retry build
- Build succeeds
Root Cause
When struct definitions change in one crate but cargo's incremental compilation cache for dependent crates is not invalidated, the dependent crates reference the old struct definition from cache. This is most common when:
- Pulling changes from git
- Adding/removing struct fields
- Modifying struct field visibility
- Working across multiple workspace crates with dependencies
Reproduction
cd codex-rs
# 1. Add temporary field to tui/src/cli.rs Cli struct
# pub test_field: bool,
# 2. Build with new field
cargo build --bin codex
# 3. Remove the field from source
# 4. Clean only codex-cli (not codex-tui)
cargo clean -p codex-cli
# 5. Add field back to source
# 6. Try to build
cargo build --bin codex
# Error: no field `test_field` on type `codex_tui::Cli`
# 7. Manual fix required
cargo clean -p codex-tui
cargo build --bin codex
# Now succeeds
Impact
- Frequency: Occasional, but blocks all development when it occurs
- Severity: Medium - has workaround but requires manual diagnosis
- Affected: All contributors, especially after pulling struct changes
- Time Cost: 2-5 minutes per occurrence to diagnose and fix
Proposed Solution
A wrapper script that detects the 'no field...on type' error pattern, extracts the affected crate name from compiler output, automatically runs cargo clean -p <crate>, and retries the build.
This would change the UX flow to:
- Developer pulls changes
- Developer runs build script
- Script detects error, cleans cache, retries automatically
- Build succeeds without manual intervention
Environment
- Platform: All (macOS, Linux, Windows)
- Rust: stable toolchain
- Workspace: codex-rs monorepo
- Cargo: Using incremental compilation (default)
Workaround
When encountering 'no field...on type' errors:
cargo clean -p <affected-crate>
cargo build --bin codex
Or for full clean:
cargo clean
cargo build --bin codex
Issue Description
The intent of this report is to document a build failure pattern where cargo's incremental compilation cache references outdated struct definitions after fields are added or modified in workspace crates, causing compilation to fail with 'no field...on type' errors despite the field existing in source.
Current UX Flow (Broken)
Cliincodex-tui)cargo build --bin codexerror[E0609]: no field 'spec' on type 'codex_tui::Cli'cargo clean -p codex-tuiRoot Cause
When struct definitions change in one crate but cargo's incremental compilation cache for dependent crates is not invalidated, the dependent crates reference the old struct definition from cache. This is most common when:
Reproduction
Impact
Proposed Solution
A wrapper script that detects the 'no field...on type' error pattern, extracts the affected crate name from compiler output, automatically runs
cargo clean -p <crate>, and retries the build.This would change the UX flow to:
Environment
Workaround
When encountering 'no field...on type' errors:
Or for full clean: