[英]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.