I'm running a GitHub Actions workflow and it is failing with the following error.
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.
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.
The image runs with user cirrus
. It is also required to provide the full path:
sudo /home/cirrus/sdks/flutter/bin/flutter pub get
From GitHub docs :
The Linux and macOS virtual machines both run using passwordless 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.
Instead of adding sudo to all the steps that fail you can also just modify the container configuration:
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. Including the /github
directory that is causing trouble for you. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.