-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo clean --offline
fails
#12989
Comments
When using the |
I see. I'm running in a CI context where my goal is to clean up packages built for the current workspace but leave dependencies intact so they can be cached; this should minimize cache usage without negatively affecting build times too much since workspace package build outputs are very likely to be invalidated anyway. My command right now looks like this: cargo clean -p `cargo metadata --no-deps --offline --format-version 1 | jq -r '[.workspace_members[]|split(" ")|.[0]]|join(" ")'` Adding a special case for |
Have you looked into the third-party cargo-sweep? I'm also hoping #5931 will help by having dependency caches separate from caches for local packages. You can then combine that with #12633 which will help clear out per-user cache entries from prior builds. |
If you have a common prefix for all workspace members, you can use glob syntax like |
Yes, but I'm hoping to reuse this same ci script for independent rust projects, so I prefer my general solution despite being a bit longer.
This would be ideal. The cache is keyed on lock files, host os, and target triple, so "removing stale artifacts" and gc in general is irrelevant in my case (except maybe gc cloned git repos). If deps change it will fail to match the key so deps will be rebuilt, a new cache entry will be created, and the old one will just fall off. Even if it was available today I'd still prefer to rebuild the cache from scratch instead of trying to keep it up to date by gc-ing it. |
Problem
In some cases cargo clean refuses to execute in offline mode. I can't imagine any valid reason why cargo clean would need access to the network to perform workspace cleaning activity.
Steps
cargo clean
rm -r ~/.cargo/git
rm -r ~/.cargo/registry
cargo clean --offline -p <project-name>
error: failed to load source for dependency 'modular-bitfield'
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: