Skip to content
Skip to Content
Remote cache

Sync

Pull and push cache entries without the daemon

kache sync talks directly to the configured remote. It is useful for explicit CI warm and publish steps. It lists the remote to compare it with the local store, so on S3 its credentials need s3:ListBucket.

Commands sharing the same local cache directory run one at a time. A second sync waits for the first to finish, including transfers and imports. Commands using different cache directories can run concurrently.

kache sync                 # pull, then push
kache sync --pull          # download only
kache sync --push          # upload only
kache sync --dry-run       # show the plan
kache sync --all           # ignore pull filtering
kache sync --workspace     # pull discovery for workspace members only
kache sync --allow-partial # report failures but exit successfully

Filtering

Pull and push use different scopes:

  • Pull uses the selected workspace's Cargo.lock, with package-name hyphens replaced by underscores, plus actual target names from cargo metadata --locked --all-features. This includes renamed library targets. With no usable lockfile it lists the full remote.
  • --workspace pulls only workspace members' targets. It conflicts with --all.
  • Push uploads only workspace members' targets. Outside a Cargo project it uploads every local entry. Build-script runs are never pushed. With remote writes off (remote_readonly or the CI write policy), push uploads nothing.
  • --manifest-path selects the project for both pull and push. Without it, Kache finds the nearest ancestor Cargo.toml. A manifest that Cargo cannot read fails project-scoped operations before connecting to the remote. --pull --all skips Cargo metadata and can run without a valid Cargo project.

Resolving dependency targets can fetch Cargo dependency sources on a fresh machine. It respects Cargo's offline configuration and does not change Cargo.lock. Push-only, --workspace, and combined sync --all operations use cargo metadata --no-deps and do not fetch dependency sources. sync --pull --all skips Cargo entirely.

With only a standalone Cargo.lock, Kache warns and uses normalized package names. If dependency metadata fails inside a Cargo project, Kache warns and uses normalized lockfile names plus workspace targets. This fallback can miss renamed dependency libraries. Run cargo fetch --locked and retry, or use kache sync --pull --all to pull every remote crate without resolving dependencies.

Narrowing the initial pull does not disable on-demand dependency restores during a later daemon-backed build.

CI sequence

kache sync --pull
cargo build --release
kache daemon stop

The daemon uploads new entries in the background, dependencies included. kache daemon stop gives its upload queue up to 30 seconds before it exits; see CI setup for what happens to the rest. Inside a Cargo workspace, kache sync --push uploads only that workspace's own crates. Use it when you run without the daemon and those crates are what you want to publish.

Failure behavior

All scheduled operations drain before the command exits. Any transfer or import failure makes the command nonzero unless --allow-partial is set. --allow-partial covers transfers and imports only. A remote Kache cannot connect to, or a listing that fails, still fails the command.

cache.s3_concurrency / KACHE_S3_CONCURRENCY (default 16) controls parallel operations for all remote backends.

Use --dry-run to inspect the planned crate names and truncated keys. Object sizes are not available from the listing plan.

Available for:
Apple macOS logomacOSMicrosoft Windows logoWindowsLinux logoLinux
Download Kunobi