From e7652bb906ca4336fbc060194bb531910043ed24 Mon Sep 17 00:00:00 2001 From: r007 Date: Sat, 10 Oct 2026 12:41:33 +0400 Subject: [PATCH] Fix mdBook install failing on cached cargo bin The cargo cache restored ~/.cargo/bin without cargo's install records (.crates.toml and .crates2.json). cargo install then found mdbook in the destination it did not track and failed with "binary `mdbook` already exists in destination". Cache the records together with the binaries, and bump the cache key to books-v2: GitHub caches are not overwritten once saved, so the old entry without the records would keep being restored under the same key. Co-Authored-By: Claude Haiku 5.5 --- .github/workflows/ci.yml | 7 +++++-- .github/workflows/pages.yml | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8334ce2..c743f11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,15 +36,18 @@ jobs: - name: Кэш cargo uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: + # Метаданные cargo нужны, чтобы cargo install узнавал бинарники из кэша; v2 в ключе сбрасывает старый кэш без них. path: | ~/.cargo/bin + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db target - key: ${{ runner.os }}-books-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-books-v2-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-books- + ${{ runner.os }}-books-v2- - name: Установка инструментов mdBook run: | cargo install --locked mdbook --version 0.5.4 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index fbc6ef6..878a745 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -33,15 +33,18 @@ jobs: - name: Кэш cargo uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: + # Метаданные cargo нужны, чтобы cargo install узнавал бинарники из кэша; v2 в ключе сбрасывает старый кэш без них. path: | ~/.cargo/bin + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json ~/.cargo/registry/index ~/.cargo/registry/cache ~/.cargo/git/db target - key: ${{ runner.os }}-books-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-books-v2-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-books- + ${{ runner.os }}-books-v2- - name: Установка инструментов mdBook run: |