java system_error ai_generated true

无法加载构建脚本 '/home/user/project/build.gradle':无法打开缓存目录 '/home/user/.gradle/caches/8.5/build-cache-1'(权限被拒绝)。

Build script '/home/user/project/build.gradle' could not be loaded: Could not open cache directory '/home/user/.gradle/caches/8.5/build-cache-1' (Permission denied)

ID: java/gradle-missing-build-script-cache

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2025-08-10首次发现

版本兼容性

版本状态引入弃用备注
8+ active

根因分析

Gradle 缓存目录由其他用户拥有或权限不正确,阻止 Gradle 写入。

English

The Gradle cache directory is owned by another user or has incorrect permissions, preventing Gradle from writing to it.

generic

解决方案

  1. 95% 成功率 Fix permissions on the cache directory
    sudo chown -R $USER:$USER ~/.gradle/caches/8.5/build-cache-1
  2. 90% 成功率 Clear the cache directory and let Gradle recreate it
    rm -rf ~/.gradle/caches/8.5/build-cache-1

无效尝试

常见但无效的做法:

  1. Changing the cache directory to a different path without fixing permissions 70% 失败

    The new path may also have permission issues or be non-existent.

  2. Running Gradle with sudo 80% 失败

    This can cause ownership issues and is a security risk.