Skip to content

Commit aaefd99

Browse files
fix(cargo): symlink project CARGO_HOME/bin to ~/.cargo/bin, add PATH
The _setup-cargo-home task was symlinking to the mise install dir, which contains relative multicall symlinks that break when rustup is missing from that directory. Instead: - Symlink project-local CARGO_HOME/bin/<tool> to ~/.cargo/bin/<tool> - Add ~/.cargo/bin to PATH in cargo.yml env so rustup is findable - Document the three-directory structure in AGENTS.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 37fd360 commit aaefd99

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ See [Tauri Architecture](docs/tauri-architecture.md) for full details.
7272

7373
### Rust Toolchain (mise + rustup)
7474

75-
mise manages the Rust version (via `.tool-versions`) but delegates to rustup under the hood. The mise install directory (`~/.local/share/mise/installs/rust/<version>/`) contains symlinks like `cargo -> rustup` — these are rustup multicall symlinks that require the `rustup` binary to be resolvable. The `cargo:_setup-cargo-home` task in `taskfiles/cargo.yml` creates `$CARGO_HOME/bin` symlinks pointing directly at `$CARGO_HOME/bin/rustup` (the real binary) rather than chaining through the mise install dir, which would break if the relative `rustup` target is missing.
75+
Three directories are involved — do NOT cross-link them:
76+
77+
| Directory | Purpose | Managed by |
78+
|-----------|---------|------------|
79+
| `~/.cargo/bin/` | Real rustup binary + multicall symlinks (`cargo -> rustup`) | rustup |
80+
| `~/.local/share/mise/installs/rust/<version>/` | Relative multicall symlinks (`cargo -> rustup`) + rustup copy | mise |
81+
| `$CARGO_HOME/bin/` (project-local `.cache/cargo/bin/`) | Symlinks to `~/.cargo/bin/<tool>` | `cargo:_setup-cargo-home` task |
82+
83+
`cargo.yml` adds `~/.cargo/bin` to PATH so rustup tools are always findable. The `_setup-cargo-home` task symlinks project-local `CARGO_HOME/bin/` to `~/.cargo/bin/` — never to the mise install dir, which has its own internal symlink structure.
7684

7785
## Queue and Shuffle Behavior
7886

taskfiles/cargo.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ version: "3.0"
33
set: ['e', 'u', 'pipefail']
44
shopt: ['globstar']
55

6+
env:
7+
PATH: "{{.HOME}}/.cargo/bin:{{.PATH}}"
8+
69
tasks:
710
_setup-cargo-home:
811
internal: true
@@ -11,13 +14,13 @@ tasks:
1114
- |
1215
cargo_bin="$CARGO_HOME/bin"
1316
mkdir -p "$cargo_bin"
14-
rustup_bin="$cargo_bin/rustup"
15-
if [[ ! -x "$rustup_bin" ]]; then
16-
echo "error: rustup not found at $rustup_bin" >&2
17-
exit 1
18-
fi
17+
src="${HOME}/.cargo/bin"
1918
for tool in cargo cargo-clippy cargo-fmt rustc rustdoc rustfmt; do
20-
ln -sf "$rustup_bin" "$cargo_bin/$tool"
19+
if [[ ! -x "$src/$tool" ]]; then
20+
echo "error: $src/$tool not found" >&2
21+
exit 1
22+
fi
23+
ln -sf "$src/$tool" "$cargo_bin/$tool"
2124
done
2225
status:
2326
- test -L "$CARGO_HOME/bin/cargo" && test -e "$CARGO_HOME/bin/cargo"

0 commit comments

Comments
 (0)