Skip to content

Fix CI clippy failure by caching ~/.rustup/toolchains#3

Merged
sij411 merged 1 commit into
fedify-dev:mainfrom
dahlia:fix/ci
May 20, 2026
Merged

Fix CI clippy failure by caching ~/.rustup/toolchains#3
sij411 merged 1 commit into
fedify-dev:mainfrom
dahlia:fix/ci

Conversation

@dahlia
Copy link
Copy Markdown
Member

@dahlia dahlia commented May 19, 2026

jdx/mise-action@v4 caches ~/.local/share/mise, which is where mise stores a symlink to the actual Rust toolchain in ~/.rustup. On a cache hit, mise restores the symlink but never touches ~/.rustup itself, sees the symlink, concludes the toolchain is installed, and skips running rustup. When cargo runs next, rustup lazily installs the toolchain with only its three minimal components (rustc, rust-std, cargo), omitting clippy. cargo clippy then fails.

The fix adds an actions/cache@v5 step to cache ~/.rustup/toolchains, keyed on rustup-v1-{runner.os}-{hash of mise.toml}. With the full toolchain present before mise-action runs, mise finds both the symlink and the files it points to, and no lazy reinstall occurs.

This didn't reproduce locally because clippy was already installed as part of the local Rust setup, making the missing-component path unreachable.

To force-invalidate the rustup cache later, bump the key prefix from rustup-v1 to rustup-v2 in .github/workflows/main.yaml, or delete the cache directly with gh cache delete.

This pull request was diagnosed and written with Claude Code (Claude Sonnet 4.6).

@dahlia dahlia requested a review from sij411 May 19, 2026 12:01
@dahlia dahlia added the bug Something isn't working label May 19, 2026
Copy link
Copy Markdown
Contributor

@sij411 sij411 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I thought caching ~/.rustup/toolchains would be enough, because clippy is stored as a rustup component under the toolchain directory. But after looking at common Rust CI patterns, I think explicitly installing/selecting the required Rust components is cleaner. The cache should optimise CI speed, not decide whether clippy exists. What do you think? I want to hear your opinion on this.

@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented May 20, 2026

@sij411 The cache miss case is actually fine. When there's no mise cache, mise does a full fresh install and downloads all 7 components including clippy. The failure only happens in a specific half-cached state: the mise cache hits (restoring only the symlink in ~/.local/share/mise), but ~/.rustup is absent. mise sees the symlink, assumes the toolchain is already installed, and skips running rustup. rustup then lazily installs just the 3 minimal components (rustc, rust-std, cargo) when cargo first runs, leaving clippy out.

The fix eliminates that half-cached state rather than relying on cache presence to supply clippy. Both cache keys are tied to hashFiles('mise.toml'), so the mise cache and the rustup toolchain cache always hit or miss together. On a miss, mise installs everything fresh, clippy included.

I agree the real fix belongs upstream in mise: it should either cache ~/.rustup/toolchains alongside ~/.local/share/mise, or check that the symlink target actually exists before skipping installation. That's being tracked in jdx/mise-action#215, but it's out of scope here.

Previously, jdx/mise-action cached only ~/.local/share/mise, which
stores a symlink to the actual rustup toolchain in ~/.rustup.  On a
cache hit, mise saw the symlink and skipped reinstallation, leaving
~/.rustup empty.  rustup then lazily installed only 3 minimal
components (rustc, rust-std, cargo) when cargo first ran, omitting
clippy — causing `cargo clippy` to fail.

The fix adds an actions/cache@v5 step to also cache
~/.rustup/toolchains, keyed on the OS and a hash of mise.toml.  On
a warm cache the full toolchain (including clippy) is restored before
mise-action runs, so mise finds both its symlink and the real files
intact.

To force-invalidate the rustup cache, bump the key prefix from
rustup-v1 to rustup-v2.  For the mise cache, pass
cache_key_prefix: mise-v2 to jdx/mise-action, or use:
  gh cache delete --all --repo fedify-dev/feder

Assisted-by: Claude Code:claude-sonnet-4-6
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented May 20, 2026

Also amended the commit to add a comment in .github/workflows/main.yaml above the cache step, linking to jdx/mise-action#215 for future reference.

@dahlia dahlia requested a review from sij411 May 20, 2026 06:36
@sij411
Copy link
Copy Markdown
Contributor

sij411 commented May 20, 2026

That was a upstream bug, got it. Thanks for investigating!

@sij411 sij411 merged commit e1e0a48 into fedify-dev:main May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants