Skip to content
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

fatal: detected dubious ownership in repository at '/github/workspace' #27

Closed
littleGnAl opened this issue Mar 1, 2024 · 8 comments · Fixed by getsentry/sentry-dart#1918

Comments

@littleGnAl
Copy link

I run into an issue when using the axel-op/dart-package-analyzer@v3 recently, the error log

Running pana
  {"logName":"pana","level":"WARNING","message":"Flutter SDK path was not specified, pana will use the default Dart SDK to run `dart analyze` on Flutter packages."}
  {"logName":"pana","level":"INFO","message":"Running `dart --version`..."}
  {"logName":"pana","level":"INFO","message":"Running `flutter --no-version-check --version --machine`..."}
  {"logName":"pana","level":"INFO","message":"Running `git rev-parse --show-toplevel`..."}
  {"level":"SHOUT","message":"Problem analyzing /github/workspace","error":"Failed to run `rev-parse --show-toplevel`.\nfatal: detected dubious ownership in repository at '/github/workspace'\nTo add an exception for this directory, call:\n\n\tgit config --global --add safe.directory /github/workspace","stackTrace":"#0      runGit (package:pana/src/tool/git_tool.dart:41:5)\n<asynchronous suspension>\n#1      withTempDir (package:pana/src/utils.dart:134:12)\n<asynchronous suspension>\n#2      runGitIsolated (package:pana/src/tool/git_tool.dart:52:10)\n<asynchronous suspension>\n#3      _detectGitRoot (package:pana/src/package_analyzer.dart:274:14)\n<asynchronous suspension>\n#4      PackageAnalyzer.inspectDir.<anonymous closure> (package:pana/src/package_analyzer.dart:95:23)\n<asynchronous suspension>\n#5      withTempDir (package:pana/src/utils.dart:134:12)\n<asynchronous suspension>\n#6      main (file:///root/.pub-cache/hosted/pub.dev/pana-0.22.2/bin/pana.dart:2[49](https://github.com/AgoraIO-Extensions/Agora-Flutter-SDK/actions/runs/8075870137/job/22154729575?pr=1585#step:6:51):19)\n<asynchronous suspension>\n"}
Error: Pana exited with code 1

here's the failed job
https://github.com/AgoraIO-Extensions/Agora-Flutter-SDK/actions/runs/8075870137/job/22154729575?pr=1585

After some search, actions/runner-images#6775, I tried to add this as a workaround in my step, but it's no luck.

git config --global --add safe.directory '/github/workspace'

I'm not very sure if it should be added inside the Dockerfile, I think it can easily reproduce this issue with the following workflow config

jobs:
  flutter_codestyle_check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
      - uses: axel-op/dart-package-analyzer@v3
        id: analysis
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
@axel-op
Copy link
Owner

axel-op commented Mar 1, 2024

Hello,

Thanks for reporting this issue.

After some search, actions/runner-images#6775, I tried to add this as a workaround in my step, but it's no luck.

The problem is that pana runs Git in a way that prevents any custom config to be used, this is why your workaround didn't work.

I fixed the issue by assigning the ownership of the Git directory to the user set in the container.

Btw, this issue failed my automated tests recently so it shouldn't have made its way to you, but I thought it was a bug in my tests and I changed the tests instead of the code... I'll be more careful next time.

@axel-op axel-op closed this as completed Mar 1, 2024
@JaffaKetchup
Copy link

Thanks @axel-op :) no worries about the small break

@littleGnAl
Copy link
Author

@axel-op It works now, thanks for your work.

@buenaflor
Copy link

it's still failing for us, anything we're doing wrong? getsentry/sentry-dart#1918

@axel-op
Copy link
Owner

axel-op commented Mar 5, 2024

@buenaflor Thanks for notifying it. Here's what I did:

  • The process changing the ownership of the Git directory is now awaited to ensure it has completed before running the analysis.
  • Logs have been added in case the process returns an error.

Can you please retry the workflow?

@buenaflor
Copy link

Still failing unfortunately :(

axel-op added a commit that referenced this issue Mar 5, 2024
@axel-op
Copy link
Owner

axel-op commented Mar 5, 2024

I think I found the root cause and definitely fixed the issue. Your package is located in a subdirectory. My initial fix acquires the ownership of this subdirectory only but not of the root repository. The problem is that Git commands are run from the root.

I implemented a fix and added a new test to prevent any regression. Tell me if this solves your issue :)

@buenaflor
Copy link

works now, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants