Skip to content

New Cargo build dir layout breaks caching for packages with hyphenated names #370

Description

@claytonwramsey

Hi! First time opening an issue, so let me know if I've missed anything important :).

rust-lang/cargo#17258 (merged 2026-07-24) uses a new path format for crates. Version 1 used <pkg>-<hash>, which rust-cache assumes, but this is no longer the case. Now caching is broken for crates with hyphenated crate names.

A temporary fix for users is to use the environment variable __CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT=1 before a fix lands. However, this variable's effect is internal and unstable for Cargo and could disappear in a future release. To do so, you can do something like this in your actions YAML file:

env:
  __CARGO_TEMPORARY_BUILD_DIR_NEW_LAYOUT_OPT_OUT: "1"

I have vibe-coded a minimal reproduction for the issue, available at https://github.com/claytonwramsey/rust-cache-buildir-repro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions