checkout: /github/home/.gitconfig does not exist for container runs
Issue
If running a job that uses a container like the below, the file /github/home/.gitconfig will not exist, even after checkout runs a config command.
example:
runs-on: ubuntu-latest
container:
image: alpine
- Checkout runs, and runs
/usr/bin/git config --global --add safe.directory /__w/sat/sat - The global .gitconfig does not exist
- Any calls to git remain unsafe/dubious
The safe.directory settings set by the command git config --global --add safe.directory <path> is a no-op.
Workaround
Use the --system scope over --global:
$ git config --system --add safe.directory <path>
example:
runs-on: ubuntu-latest
container:
image: alpine
steps:
- uses: actions/checkout@v3
- run: git config --system --add safe.directory <path>
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 45
- Comments: 17
Links to this issue
Commits related to this issue
- Try potential fix Via https://github.com/actions/checkout/issues/1169#issue-1580582826 — committed to kobaltcore/renpyfmt by kobaltcore 4 years ago
- Fix CI (#1) * Print some debug information * Try potential fix Via https://github.com/actions/checkout/issues/1169#issue-1580582826 * Would be great if I didn't fat-finger the fix, rip * ... — committed to kobaltcore/renpyfmt by kobaltcore 4 years ago
- trying to add safe path (https://github.com/actions/checkout/issues/1169) — committed to waikato-ufdl/waikato-ufdl.github.io by fracpete 4 years ago
- Try to fix git config issue https://github.com/actions/checkout/issues/1169 — committed to attoyss2023/attoyss2023.github.io by jagot 4 years ago
- Try to fix git config issue (#1) https://github.com/actions/checkout/issues/1169 https://github.com/shalzz/zola-deploy-action/issues/56 — committed to attoyss2023/attoyss2023.github.io by jagot 4 years ago
- temp_fix: broken CI actions/checkout#1169 — committed to grassrootseconomics/cic-custodial by kamikazechaser 4 years ago
- use goreleaser-cross:v1.19.2 see https://github.com/actions/checkout/issues/1169 — committed to Erope/nezha by Erope 4 years ago
- Fix Debian GitHub build & zstd CMake error (#200) Summary: 1. Workaround for Debian Docker image bug that is breaking Debian build on GitHub (Explicitly mark Git repo as safe). 2. Pin zstd to a commi... — committed to facebook/CacheLib by wonglkd 4 years ago
- Fix "detected dubious ownership" issue per https://github.com/actions/checkout/issues/1169 — committed to namoscato/action-tinify by namoscato 4 years ago
- Fix notebook action issue (actions/checkout#1169) — committed to lrzpellegrini/avalanche by lrzpellegrini 4 years ago
- try alter github action v2 with https://github.com/actions/checkout/issues/1169 — committed to xjlin0/attendees32 by xjlin0 4 years ago
- change based on https://github.com/actions/checkout/issues/1169 — committed to xjlin0/attendees32 by xjlin0 4 years ago
- fix(ci): fix dubious ownership error - workaround from https://github.com/actions/checkout/issues/1169#issue-1580582826 - full error: fatal: detected dubious ownership in repository at '/__w/cambridge... — committed to SaadiSave/cambridge-asm by SaadiSave 4 years ago
- Work around 'dubious ownership' github issue See: https://github.com/actions/checkout/issues/1169 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com> — committed to sgallagher/sscg by sgallagher 3 years ago
- Work around 'dubious ownership' github issue See: https://github.com/actions/checkout/issues/1169 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com> — committed to sgallagher/sscg by sgallagher 3 years ago
- Work around 'dubious ownership' github issue See: https://github.com/actions/checkout/issues/1169 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com> — committed to sgallagher/sscg by sgallagher 3 years ago
- Work around 'dubious ownership' github issue See: https://github.com/actions/checkout/issues/1169 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com> — committed to sgallagher/sscg by sgallagher 3 years ago
- Work around 'dubious ownership' github issue See: https://github.com/actions/checkout/issues/1169 Signed-off-by: Stephen Gallagher <sgallagh@redhat.com> — committed to sgallagher/sscg by sgallagher 3 years ago
- add safe directory workaround for https://github.com/actions/checkout/issues/1169 — committed to codecheckers/register by nuest 3 years ago
- fix permission error for safe directory Summary: In D48757822, we added the safe directory to the system gitconfig. However, for native runs of workflows including Ubuntu-20 and Ubuntu-22, this does ... — committed to facebook/CacheLib by deleted user 3 years ago
The following should also work, and saves you an extra
runstep.That works for me so far
$GITHUB_WORKSPACEallows me to use that between repositories without changesI’m fixing the issue in pgxn-tools by adding this line to the
Dockerfileto disable the check inside the running container:Is there any reason that is likely to be a security issue?
Thanks for this. Adding a step to our job with
git config --system --add safe.directory $(pwd)works around the “dubious ownership” error.For info, did a little experiment and added a step to print the
idand owner ofpwd- for some reasonactions/checkout@v4checks out the repo as user 1001, even though there is no such user in the container. Output from CIFor reference, the upstream change to git that performs the “dubious ownership” check appears to be https://github.com/git/git/commit/f4aa8c8bb11dae6e769cd930565173808cbb69c8
I banged my head on what I think is this issue all day. Consider this config:
This results in this error:
Shouldn’t we be able to do Git stuff with the repo in a container? Curious, I tried changing the last line to:
It simply exits with no error message, as in this run:
Is that because the global config file is missing? I find it simply wild that there is no error message.
Anyway, I then tried setting the global config:
And that works. But I admit I’m pretty confused about why this isn’t set up by default when an action starts.
So fine, I can manually put this line into my workflow YAML files, but I’m mystified as to why it’s necessary. Is it this issue or am I missing something?
Thanks for bearing with my examples.
@xjlin0, please read my previous comment. This is specific to containers
With “dubious ownership” errors, the workaround doesn’t work for me, when I switch from --global to --system, it fails with permission error
results:
Any suggestions? thanks!