Permission denied to create file in "/github/home/" folder

I have this simple workflow to build a Flutter app, but it is failing to create a file at the home /github/home/ folder.

Run flutter pub get

FileSystemException: Cannot create file, path = '/github/home/.flutter' (OS Error: Permission denied, errno = 13)
#0 _File.throwIfError (dart:io/file_impl.dart:643:7)
#1 _File.createSync (dart:io/file_impl.dart:281:5)

I attached the container initialization log and it is possible to see that the docker image has the home volume mapped to it.

name: Dart 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
      working-directory: my_app

Here are the logs for this action.

https://github.com/actions/docker/files/3587247/initialize-containers.log

https://github.com/actions/docker/files/3587248/install-dependencies.log

1 Like

I’m not familiar with the cirrusci/flutter container.  What user is that running as?  You may need to run some commands in that container as root.

1 Like

flutter pub get will create ~/.pub-cache

It works on Gitlab CI with the same image, but doesn’t on GitHub Action

2 Likes

Solved it by adding “sudo” before any command that requires permission. It also requires that the full path of Flutter is referenced when executing the commands.

The image was running with “cirrus” user and therefore didn’t have permission.

More info here: https://stackoverflow.com/a/58469603/3231778

2 Likes