简体   繁体   English

GitHub 操作工作流程错误:权限被拒绝

[英]GitHub Actions workflow error: Permission denied

I'm running a GitHub Actions workflow and it is failing with the following error.我正在运行 GitHub 操作工作流,但由于以下错误而失败。

Unhandled exception:
FileSystemException: Cannot create file, path = '/github/home/.flutter' (OS Error: Permission denied, errno = 13)

I looked in Workflow syntax for GitHub Actions but couldn't find any instruction to solve this.我查看了 GitHub Actions 的工作流语法,但找不到任何说明来解决这个问题。

My build file is looking like this:我的构建文件如下所示:

name: Flutter CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    container:
      image:  cirrusci/flutter:v1.7.8-hotfix.4

    steps:
    - uses: actions/checkout@v1
    - name: Install dependencies
      run: flutter pub get
      working-directory: my_app
    - name: Run tests
      run: flutter test

Finally got the time to look at it and adding sudo solved it. 终于有时间查看它并添加sudo解决了它。

The image runs with user cirrus . 该图像与用户cirrus一起运行。 It is also required to provide the full path: 还需要提供完整路径:

sudo /home/cirrus/sdks/flutter/bin/flutter pub get

From GitHub docs : 来自GitHub docs

The Linux and macOS virtual machines both run using passwordless sudo. Linux和macOS虚拟机均使用无密码sudo运行。 When you need to execute commands or install tools that require more privileges than the current user, you can use sudo without needing to provide a password. 当您需要执行命令或安装需要比当前用户更多特权的工具时,可以使用sudo而不需要提供密码。

Instead of adding sudo to all the steps that fail you can also just modify the container configuration:除了将 sudo 添加到所有失败的步骤之外,您还可以只修改容器配置:

container:
  image:  cirrusci/flutter:v1.7.8-hotfix.4
  options: --user root

Explanation: The problem is being caused because the default user on the cirrusci/flutter:v1.7.8-hotfix.4 image doesn't have access to certain directories that are mounted into this docker image by github.说明:该问题是由于 cirrusci/flutter:v1.7.8-hotfix.4 映像上的默认用户无权访问由 github 挂载到此 docker 映像中的某些目录而引起的。 Including the /github directory that is causing trouble for you.包括给您带来麻烦的/github目录。 Adding options: --user root to the container configuration makes sure that the default user becomes root so that you do not need to sudo at every single step.添加options: --user root user options: --user root到容器配置可确保默认用户成为 root,这样您就无需在每一步都执行 sudo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 权限被拒绝:Github 操作上的共享卷写入和读取失败 - Permission denied: Shared volume write and Read failing on Github Actions Github 操作中的手动工作流触发器 - Manual workflow triggers in Github Actions 为什么 Docker 文件系统权限在 GitHub 操作上表现不同(服务器上的权限被拒绝) - Why are Docker filesystem permissions behaving differently on GitHub Actions (Permission denied on server) Github 操作/缓存对我的工作流程没有影响 - Github actions/cache has no effect on my workflow 无法在 Github Actions 工作流程上访问 localhost - Localhost can not be accessed on Github Actions workflow 如何在 GitHub Actions 工作流中实现语义版本控制? - How to implement semantic versioning in GitHub Actions workflow? Github 操作工作流到 docker 容器环境 - Github actions workflow to docker container environment Github 工作流程:请求的资源访问被拒绝 - Github workflow: requested access to the resource is denied Github 将容器推送到 Github 容器注册表的操作工作流程失败并显示“未经身份验证” - Github Actions workflow for pushing a container to Github Container Registry fails with "unauthenticated" Dokku Deploy Github 操作,权限被拒绝(公钥) - Dokku Deploy Github action, Permission denied (publickey)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM