-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: unsafe repository (REPO is owned by someone else) in other workflow steps after running checkout #766
Comments
@thboop I agree with everything you've written here, and thank you for getting the fix for this action sorted so quickly! I think I'm a little confused about why this ticket is here, though; should this be raised and tracked over at actions/runner? |
🏅 Its a good point that this is more appropriate for the runner repository, however given the nature of this breaking workflows, and the overall concern and questions folks had about what is happening and why, I though I would put it closer to where we are seeing the most users comment about this issue. I may move it in the near future over to the runner repo. |
This commit: - updates GH Actions checkout to v3 - apply additional work around stated in actions/checkout#766 This fixes the problem with the following error message: ``` fatal: unsafe repository ('/github/workspace' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /github/workspace ``` The problem is due to the security fix from the Git security vulnerability recently announced: https://github.blog/2022-04-12-git-security-vulnerability-announced/. Relevant GH issue: actions/checkout#760
This commit: - updates GH Actions checkout to v3 - apply additional work around stated in actions/checkout#766 This fixes the problem with the following error message: ``` fatal: unsafe repository ('/github/workspace' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /github/workspace ``` The problem is due to the security fix from the Git security vulnerability recently announced: https://github.blog/2022-04-12-git-security-vulnerability-announced/. Relevant GH issue: actions/checkout#760
This commit: - updates GH Actions checkout to v3 - apply additional work around stated in actions/checkout#766 This fixes the problem with the following error message: ``` fatal: unsafe repository ('/github/workspace' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /github/workspace ``` The problem is due to the security fix from the Git security vulnerability recently announced: https://github.blog/2022-04-12-git-security-vulnerability-announced/. Relevant GH issue: actions/checkout#760
This commit: - updates GH Actions checkout to v3 - apply additional work around stated in actions/checkout#766 This fixes the problem with the following error message: ``` fatal: unsafe repository ('/github/workspace' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /github/workspace ``` The problem is due to the security fix from the Git security vulnerability recently announced: https://github.blog/2022-04-12-git-security-vulnerability-announced/. Relevant GH issue: actions/checkout#760
It seems like this is insufficient if there are submodules? (log) |
This commit: - updates GH Actions checkout to v3 - apply additional work around stated in actions/checkout#766 This fixes the problem with the following error message: ``` fatal: unsafe repository ('/github/workspace' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /github/workspace ``` The problem is due to the security fix from the Git security vulnerability recently announced: https://github.blog/2022-04-12-git-security-vulnerability-announced/. Relevant GH issue: actions/checkout#760
Work around actions/checkout#766
Work around actions/checkout#766
When attempting to run the pre-commit hooks in the CI, we get this error: An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory? actions/checkout#766 suggests the issue could be because 'actions/checkout' clones the repository as a different user than is used in our custom docker container. Git then doesn't trust the repository and errors when called upon.
When attempting to run the pre-commit hooks in the CI, we get this error: An error has occurred: FatalError: git failed. Is it installed, and are you in a Git repository directory? actions/checkout#766 suggests the issue could be because 'actions/checkout' clones the repository as a different user than is used in our custom docker container. Git then doesn't trust the repository and errors when called upon.
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766).
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766).
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766).
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766).
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766).
This commit applies a hotfix for a upstream bug in [checkout/issues/766](actions/checkout#766). Co-authored-by: rickstaa <rickstaa@users.noreply.github.com>
I fixed it with :
but i dont know if it is the correct way |
More information here: actions/checkout#766 Signed-off-by: Pascal Iske <info@pascaliske.dev>
Even the action marks path as a safe directory, it overrides HOME env before. This was made intentionally (link). I don't know the exact reason though. When you run next step within workflow, HOME env is reset, and the dir becomes unsafe. Example Workflowname: Example of Missing Safe Dir
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
jobs:
test-git-config:
runs-on: ubuntu-22.04
container: ubuntu:jammy-20240111
steps:
- name: Install Git CLI
run: |
apt-get update
apt-get install git -y
- name: Checkout repository
uses: actions/checkout@v4
- name: Test Git Configuration and Environment
run: |
# Test as is, fail
echo "Testing git status command:"
git status && echo success || echo fail
# Save HOME value
ORIGINAL_HOME=$HOME
echo "Original HOME: $ORIGINAL_HOME"
# Override HOME value, mark directory as safe
export HOME=/tmp/newhome
mkdir -p $HOME
git config --global --add safe.directory /__w/checkout-action-issue/checkout-action-issue
echo "Git config added in overridden HOME"
# Test with overridden HOME, success
echo "Testing git status command:"
git status && echo success || echo fail
# Reset HOME to original value
export HOME=$ORIGINAL_HOME
echo "HOME reset to original: $HOME"
# Test again after resetting HOME
echo "Testing git status command:"
git status && echo success || echo fail
# Mark directory as safe with original HOME
git config --global --add safe.directory /__w/checkout-action-issue/checkout-action-issue
# Test after marking directory as safe with original HOME, success
echo "Testing git status command:"
git status && echo success || echo fail Output
|
Needed now, wasn't needed 4 years ago. See: actions/checkout#766
Fix indentation that perltidy complains about Use Debian tagged images for the the perl images
Add workaround for git diff issue: actions/checkout#766 Fix indentation that perltidy complains about Use Debian tagged images for the the perl images
Add workaround for git diff issue: actions/checkout#766 Fix indentation that perltidy complains about Use Debian tagged images for the the perl images Use newer checkout version to avoid node deprecation warnings
Also squashed * Fix actions (#102) * Fix clang-format (#103) * Pass CLANG_RELEASE explicitly (#104) * Fix clang-format (#105) * Fix clang-format (#106) * Fix clang-format (#107) * Fix clang-format (#108) * Fix clang-format (#109) * Fix clang-format (#110) * Fix clang-format (#111) * Fix clang-format (#112) * Fix clang-format (#113) * Fix clang-format (#114) * Fix clang-format (#115) * Fix clang-format (#116) Persistent workflow errors were caused by actions/checkout#766 and badly configured `on:` workflow trigger
Description
Git recently pushed a change in response to a cve that causes git commands to fail if the parent directory changes ownership from the current directory. You may see errors like
on self hosted runners, or if your job uses a container.
Workaround: Checkout is failing
This was fixed in the checkout action #760
Please update to the latest version of checkout.
v3
,v3.0.1
,v2
andv2.4.1
all contain the fix for this issue. If you are still seeing the checkout action fail on these versions, please file an issue.Workaround: Other steps are failing
Since we don't persist that configuration, you may still see this error if your job uses git commands outside of the checkout action. If so, you just need to set the configuration value yourself.
Simply set the
GITHUB_WORKSPACE
as a safe directory.If your github workspace starts off with
//
, you may need to set it viaIf you are failing inside a container action, you will need to run this inside your container action script.
Why is the parent directory owned by a different user?
When the runner maps the working directory mounts into your job container or step container they are owned by the runner user, not the container user, causing this issue. While any folders created may be owned by the container user.
Why don't we persist the configuration we use in
actions/checkout
We could try to persist this temporary global configuration we set in checkout for the duration of your job, but there are few problems with that:
Whats next
This is better solved at an actions ecosystem level, rather than solving it in the
checkout
action. That way, users not using checkout and users using container actions can take advantage of that solution. This is something our team is actively looking into now.The text was updated successfully, but these errors were encountered: