# 错误：无法求解：无法计算缓存键：无法计算引用 moby::abc123 的校验和："/some/path"：未找到

- **ID:** `cicd/docker-buildkit-cache-mount-error`
- **领域:** cicd
- **类别:** build_error
- **错误码:** `BUILDKIT_CACHE_MOUNT`
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

Docker BuildKit 缓存挂载目标路径不存在或无效，通常由于构建上下文中缺少目录或 --mount=type=cache,target= 路径拼写错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Docker 24.0.5 | active | — | — |
| Docker 25.0.0 | active | — | — |
| BuildKit v0.12.0 | active | — | — |

## 解决方案

1. ```
   Ensure the cache mount target directory exists in the Dockerfile by adding a RUN mkdir -p /some/path before the cache mount instruction.
   ```
2. ```
   Use absolute paths and avoid symlinks: change --mount=type=cache,target=/var/cache/apt to a unique path like /cache/apt and ensure no trailing spaces.
   ```

## 无效尝试

- **** — Running docker system prune -a removes all cache but doesn't fix the underlying path issue; cache mounts still fail. (90% 失败率)
- **** — Adding --no-cache flag forces rebuild but doesn't address the missing directory; error persists on next build. (80% 失败率)
- **** — Changing the cache mount from type=cache to type=bind may work but defeats caching purpose and can cause permission issues. (50% 失败率)
