Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git permissions issues when running on self hosted runner #228

Closed
yangcheng opened this issue May 17, 2023 · 3 comments
Closed

Git permissions issues when running on self hosted runner #228

yangcheng opened this issue May 17, 2023 · 3 comments

Comments

@yangcheng
Copy link

I try to use this action on ec2 with self host runner, eventual failure on

Unhandled exception:
Null check operator used on a null value
#0 getHomeDirectory (package:unified_analytics/src/utils.dart:83:27)
#1 new Analytics (package:unified_analytics/src/analytics.dart:113:38)
#2 getDefaultAnalytics (package:flutter_tools/src/globals.dart:97:38)
#3 analytics (package:flutter_tools/src/globals.dart:93:56)
#4 _exit (package:flutter_tools/runner.dart:278:15)
#5 _handleToolError (package:flutter_tools/runner.dart:157:14)
#6 run.. (package:flutter_tools/runner.dart:114:13)
#7 _rootRunBinary (dart:async/zone.dart:1423:47)
#8 _CustomZone.runBinary (dart:async/zone.dart:1315:19)
#9 runZonedGuarded. (dart:async/zone.dart:1776:18)
#10 _Zone._processUncaughtError (dart:async/zone.dart:1081:14)
#11 _CustomZone.handleUncaughtError (dart:async/zone.dart:1285:5)
#12 Future._propagateToListeners (dart:async/future_impl.dart:734:16)
#13 Future._completeError (dart:async/future_impl.dart:592:5)
#14 Future._asyncCompleteError. (dart:async/future_impl.dart:683:7)
#15 _rootRun (dart:async/zone.dart:1399:13)
#16 _CustomZone.run (dart:async/zone.dart:1301:19)
#17 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#18 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1249:23)
#19 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#20 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#21 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#22 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:190:5)
Error: Process completed with exit code 1.

by comparing the log to default runner, I suspect it's related to git ownership issue. I had the following warning in log.

Run flutter doctor -v
fatal: detected dubious ownership in repository at '/actions-runner/_work/_tool/flutter/stable-3.10.0-x64'
To add an exception for this directory, call:

git config --global --add safe.directory /actions-runner/_work/_tool/flutter/stable-3.[10]

I tried to add git config call both before and after use action without luck

 do-the-job:
    name: Do the job on the runner
    needs: start-runner # required to start the main job when the runner is ready
    runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: 'corretto'
          java-version: '11'
      - name: fix flutter git permission
        run: git config --global --add safe.directory /actions-runner/_work/_tool/flutter/stable-3.10.0-x64
        env:
          HOME: ${{ github.workspace }}
  
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: "3.10.0"
          channel: "stable"
      
      - run: flutter doctor -v

 do-the-job:
    name: Do the job on the runner
    needs: start-runner # required to start the main job when the runner is ready
    runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          distribution: 'corretto'
          java-version: '11'
      - name: fix flutter git permission  
      - uses: subosito/flutter-action@v2
        with:
          flutter-version: "3.10.0"
          channel: "stable"
       - run: git config --global --add safe.directory /actions-runner/_work/_tool/flutter/stable-3.10.0-x64
        env:
          HOME: ${{ github.workspace }}
      - run: flutter doctor -v


both fail ,. if i just call git config without setting home, it will fail on $HOME not set.

What's the correct way to use this action on self hosted runner? I think it's related to the git things but can;t figure out how to resolve it.

Thanks !

@darhaywa
Copy link
Contributor

The following is caused by incorrect ownership/permissions for the user that setup the worker, I came across this when I realised one of my workers was running as root and then I changed it to run as a user, this error was then thrown, the easiest fix is to remove the bad folders and let GitHub fix when it does the checkout for that folder.

fatal: detected dubious ownership in repository at '/actions-runner/_work/_tool/flutter/stable-3.10.0-x64'

@RossComputerGuy
Copy link

I also got this but with GitHub's own runner, https://github.com/ExpidusOS/file-manager/actions/runs/5097074866/jobs/9163360990.

@hayesOw
Copy link

hayesOw commented Jun 14, 2023

If you are using act to run locally I managed to fix the issue by using a docker that uses a normal user called "runner" instead of root. https://github.com/catthehacker/docker_images

runs-on: ubuntu-latest

and

act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:runner-latest

Repository owner locked and limited conversation to collaborators Nov 1, 2023
@subosito subosito converted this issue into discussion #253 Nov 1, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants