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: ref HEAD is not a symbolic ref' errors #163

Closed
mpdude opened this issue Apr 23, 2020 · 4 comments · Fixed by #526
Closed

'fatal: ref HEAD is not a symbolic ref' errors #163

mpdude opened this issue Apr 23, 2020 · 4 comments · Fixed by #526

Comments

@mpdude
Copy link

mpdude commented Apr 23, 2020

Since recently, this action here fails for me when running on pull requests. Unfortunately, I don't have a public repo right now that shows the issue, but here's an abridged log:

2020-04-23T17:09:27.7823345Z ##[section]Starting: Request a runner to run this job
2020-04-23T17:09:28.5456831Z Requesting a hosted runner in current repository's account/organization with labels: 'ubuntu-18.04', require runner match: True
2020-04-23T17:09:28.6447249Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-04-23T17:09:28.6990438Z ##[section]Finishing: Request a runner to run this job
2020-04-23T17:09:36.5752069Z Current runner version: '2.169.1'
2020-04-23T17:09:36.5776942Z ##[group]Operating System
2020-04-23T17:09:36.5778351Z Ubuntu
2020-04-23T17:09:36.5779270Z 18.04.4
2020-04-23T17:09:36.5780112Z LTS
2020-04-23T17:09:36.5780972Z ##[endgroup]
2020-04-23T17:09:36.5781847Z ##[group]Virtual Environment
2020-04-23T17:09:36.5782750Z Environment: ubuntu-18.04
2020-04-23T17:09:36.5783608Z Version: 20200406.2
2020-04-23T17:09:36.5784724Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu18/20200406.2/images/linux/Ubuntu1804-README.md
2020-04-23T17:09:36.5785818Z ##[endgroup]
2020-04-23T17:09:36.5787429Z Prepare workflow directory
2020-04-23T17:09:36.5981421Z Prepare all required actions
2020-04-23T17:09:36.5997277Z Download action repository 'actions/checkout@v2'
2020-04-23T17:09:37.5055896Z Download action repository 'peter-evans/create-pull-request@v2.2.0'
...
2020-04-23T17:09:46.7064186Z ##[group]Run actions/checkout@v2
2020-04-23T17:09:46.7064895Z with:
2020-04-23T17:09:46.7065552Z   repository: xxx
2020-04-23T17:09:46.7066267Z   token: ***
2020-04-23T17:09:46.7067258Z   ssh-strict: true
2020-04-23T17:09:46.7067785Z   persist-credentials: true
2020-04-23T17:09:46.7068317Z   clean: true
2020-04-23T17:09:46.7068842Z   fetch-depth: 1
2020-04-23T17:09:46.7069367Z   lfs: false
2020-04-23T17:09:46.7069894Z   submodules: false
2020-04-23T17:09:46.7070427Z ##[endgroup]
2020-04-23T17:09:47.1399028Z Syncing repository: xxx
2020-04-23T17:09:47.1480498Z ##[group]Getting Git version info
2020-04-23T17:09:47.1481767Z Working directory is '/home/runner/work/xxx/xxx'
2020-04-23T17:09:47.1524442Z [command]/usr/bin/git version
2020-04-23T17:09:47.1664800Z git version 2.26.0
2020-04-23T17:09:47.1692902Z ##[endgroup]
2020-04-23T17:09:47.1701772Z Deleting the contents of '/home/runner/work/xxx/xxx'
2020-04-23T17:09:47.1704754Z ##[group]Initializing the repository
2020-04-23T17:09:47.1708714Z [command]/usr/bin/git init /home/runner/work/xxx/xxx
2020-04-23T17:09:47.1804047Z Initialized empty Git repository in /home/runner/work/xxx/xxx/.git/
2020-04-23T17:09:47.1815909Z [command]/usr/bin/git remote add origin https://github.com/xxx/xxx
2020-04-23T17:09:47.1860816Z ##[endgroup]
2020-04-23T17:09:47.1861665Z ##[group]Disabling automatic garbage collection
2020-04-23T17:09:47.1867242Z [command]/usr/bin/git config --local gc.auto 0
2020-04-23T17:09:47.1898144Z ##[endgroup]
2020-04-23T17:09:47.1903941Z ##[group]Setting up auth
2020-04-23T17:09:47.1912123Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2020-04-23T17:09:47.1945688Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2020-04-23T17:09:47.2343142Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2020-04-23T17:09:47.2412984Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2020-04-23T17:09:47.2689438Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2020-04-23T17:09:47.2740998Z ##[endgroup]
2020-04-23T17:09:47.2741945Z ##[group]Fetching the repository
2020-04-23T17:09:47.2749971Z [command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +9e9c4726262fb6e432e840572fe5e872b7277876:refs/remotes/pull/112/merge
2020-04-23T17:09:47.6017498Z remote: Enumerating objects: 231, done.        
...   
2020-04-23T17:09:47.6330272Z remote: Compressing objects: 100% (205/205), done.        
...
2020-04-23T17:09:47.6657662Z remote: Total 231 (delta 36), reused 87 (delta 7), pack-reused 0        
...
2020-04-23T17:09:47.7117282Z From https://github.com/xxx/xxx
2020-04-23T17:09:47.7118266Z  * [new ref]         9e9c4726262fb6e432e840572fe5e872b7277876 -> pull/112/merge
2020-04-23T17:09:47.7151923Z ##[endgroup]
2020-04-23T17:09:47.7152818Z ##[group]Determining the checkout info
2020-04-23T17:09:47.7156578Z ##[endgroup]
2020-04-23T17:09:47.7157308Z ##[group]Checking out the ref
2020-04-23T17:09:47.7164529Z [command]/usr/bin/git checkout --progress --force refs/remotes/pull/112/merge
2020-04-23T17:09:47.7362273Z Note: switching to 'refs/remotes/pull/112/merge'.
2020-04-23T17:09:47.7363209Z 
2020-04-23T17:09:47.7364362Z You are in 'detached HEAD' state. You can look around, make experimental
2020-04-23T17:09:47.7365096Z changes and commit them, and you can discard any commits you make in this
2020-04-23T17:09:47.7365778Z state without impacting any branches by switching back to a branch.
2020-04-23T17:09:47.7366157Z 
2020-04-23T17:09:47.7366821Z If you want to create a new branch to retain commits you create, you may
2020-04-23T17:09:47.7367685Z do so (now or later) by using -c with the switch command. Example:
2020-04-23T17:09:47.7368057Z 
2020-04-23T17:09:47.7368717Z   git switch -c <new-branch-name>
2020-04-23T17:09:47.7369007Z 
2020-04-23T17:09:47.7369523Z Or undo this operation with:
2020-04-23T17:09:47.7369795Z 
2020-04-23T17:09:47.7370423Z   git switch -
2020-04-23T17:09:47.7370702Z 
2020-04-23T17:09:47.7371252Z Turn off this advice by setting config variable advice.detachedHead to false
2020-04-23T17:09:47.7371671Z 
2020-04-23T17:09:47.7372336Z HEAD is now at 9e9c472 Merge fe9a2a8d7a4900aa0b5b8818146a0f9e6c6d6435 into 51e51976e0aefa42064f9777002a94ae9fd48f8f
2020-04-23T17:09:47.7374627Z ##[endgroup]
2020-04-23T17:09:47.7375604Z [command]/usr/bin/git log -1
2020-04-23T17:09:47.7405277Z commit 9e9c4726262fb6e432e840572fe5e872b7277876
...
2020-04-23T17:09:52.1943490Z ##[group]Run peter-evans/create-pull-request@v2.2.0
2020-04-23T17:09:52.1944116Z with:
2020-04-23T17:09:52.1945374Z   token: ***
2020-04-23T17:09:52.1945916Z   title: xxx
2020-04-23T17:09:52.1946538Z   branch: xxx/refs/pull/112/merge
2020-04-23T17:09:52.1948425Z   body: Please merge these changes into the refs/pull/112/merge branch
2020-04-23T17:09:52.1949230Z   commit-message: xxx
2020-04-23T17:09:52.1949939Z ##[endgroup]
2020-04-23T17:09:52.2571784Z [command]/opt/hostedtoolcache/Python/3.8.2/x64/bin/pip install --requirement /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/src/requirements.txt --no-index --find-links=/home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor
2020-04-23T17:09:52.8306694Z Looking in links: /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor
2020-04-23T17:09:52.8391757Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/GitPython-3.0.5.tar.gz
2020-04-23T17:09:53.0998662Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/PyGithub-1.45.tar.gz
2020-04-23T17:09:53.3511870Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/gitdb2-2.0.6.tar.gz
2020-04-23T17:09:53.5630600Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/Deprecated-1.2.7.tar.gz
2020-04-23T17:09:53.8512874Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/PyJWT-1.7.1.tar.gz
2020-04-23T17:09:54.0831673Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/requests-2.22.0.tar.gz
2020-04-23T17:09:54.3654746Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/six-1.14.0.tar.gz
2020-04-23T17:09:54.5719792Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/smmap2-2.0.5.tar.gz
2020-04-23T17:09:54.7827169Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/wrapt-1.11.2.tar.gz
2020-04-23T17:09:54.9964586Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/chardet-3.0.4.tar.gz
2020-04-23T17:09:55.3726962Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/idna-2.8.tar.gz
2020-04-23T17:09:55.5787565Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/urllib3-1.25.8.tar.gz
2020-04-23T17:09:55.8386183Z Processing /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/vendor/certifi-2019.11.28.tar.gz
2020-04-23T17:09:56.0590651Z Installing collected packages: smmap2, gitdb2, GitPython, wrapt, deprecated, pyjwt, chardet, idna, urllib3, certifi, requests, six, PyGithub
2020-04-23T17:09:56.0598760Z     Running setup.py install for smmap2: started
2020-04-23T17:09:56.2970406Z     Running setup.py install for smmap2: finished with status 'done'
2020-04-23T17:09:56.3000143Z     Running setup.py install for gitdb2: started
2020-04-23T17:09:56.5553330Z     Running setup.py install for gitdb2: finished with status 'done'
2020-04-23T17:09:56.5582759Z     Running setup.py install for GitPython: started
2020-04-23T17:09:56.9240652Z     Running setup.py install for GitPython: finished with status 'done'
2020-04-23T17:09:56.9294468Z     Running setup.py install for wrapt: started
2020-04-23T17:09:58.0531960Z     Running setup.py install for wrapt: finished with status 'done'
2020-04-23T17:09:58.0555469Z     Running setup.py install for deprecated: started
2020-04-23T17:09:58.3015651Z     Running setup.py install for deprecated: finished with status 'done'
2020-04-23T17:09:58.3042480Z     Running setup.py install for pyjwt: started
2020-04-23T17:09:58.5453811Z     Running setup.py install for pyjwt: finished with status 'done'
2020-04-23T17:09:58.5470331Z     Running setup.py install for chardet: started
2020-04-23T17:09:58.9414728Z     Running setup.py install for chardet: finished with status 'done'
2020-04-23T17:09:58.9464107Z     Running setup.py install for idna: started
2020-04-23T17:09:59.2594002Z     Running setup.py install for idna: finished with status 'done'
2020-04-23T17:09:59.2615865Z     Running setup.py install for urllib3: started
2020-04-23T17:09:59.5686483Z     Running setup.py install for urllib3: finished with status 'done'
2020-04-23T17:09:59.5728440Z     Running setup.py install for certifi: started
2020-04-23T17:09:59.7938223Z     Running setup.py install for certifi: finished with status 'done'
2020-04-23T17:09:59.7957545Z     Running setup.py install for requests: started
2020-04-23T17:10:00.0969154Z     Running setup.py install for requests: finished with status 'done'
2020-04-23T17:10:00.1007396Z     Running setup.py install for six: started
2020-04-23T17:10:00.3379142Z     Running setup.py install for six: finished with status 'done'
2020-04-23T17:10:00.3397582Z     Running setup.py install for PyGithub: started
2020-04-23T17:10:00.7214334Z     Running setup.py install for PyGithub: finished with status 'done'
2020-04-23T17:10:00.7537743Z Successfully installed GitPython-3.0.5 PyGithub-1.45 certifi-2019.11.28 chardet-3.0.4 deprecated-1.2.7 gitdb2-2.0.6 idna-2.8 pyjwt-1.7.1 requests-2.22.0 six-1.14.0 smmap2-2.0.5 urllib3-1.25.8 wrapt-1.11.2
2020-04-23T17:10:00.8228041Z [command]/opt/hostedtoolcache/Python/3.8.2/x64/bin/python /home/runner/work/_actions/peter-evans/create-pull-request/v2.2.0/dist/src/create_pull_request.py
2020-04-23T17:10:01.0692548Z   stderr: 'fatal: ref HEAD is not a symbolic ref'
2020-04-23T17:10:01.0696093Z ##[error]The checked out ref is not a valid base for a pull request. Unable to continue. Exiting.
2020-04-23T17:10:01.0979351Z ##[error]The process '/opt/hostedtoolcache/Python/3.8.2/x64/bin/python' failed with exit code 1

I am suspecting this might have something to do with changes in the actions/checkout@v2 action made at the end of last year, see here:

actions/checkout#23

In particular, this comment says

V2 fetches a specific SHA and retries with a few delays between before failing. Whereas V1 fetched the merge PR ref.

I don't know enough about git internals to fully understand this, but it sounds as if the actions/checkout action now always leaves us in detached head state on a SHA instead of being checked out on something that feels like a branch.

Not sure if here is the right place to fix this (or if it can be fixed), but I guess actions/checkout is such a central thing that they knew what and why they were doing it that way.

@peter-evans
Copy link
Owner

Hi @mpdude

actions/checkout has always checked out a merge commit during pull request events. This is not a branch, it's a commit that is a merge of the pull request branch and the base. This is so CI can test the merge before it happens. If you are trying to create a pull request to merge into your existing pull request branch then you don't want to do that on the merge commit, instead you should checkout the head_ref. See the documentation here.

@mpdude
Copy link
Author

mpdude commented Apr 24, 2020

That seems to fix it!

Thanks @peter-evans and sorry for not reading the documentation properly.

@ldelossa
Copy link

would the same be true for a publish event?


name: Release Actions

on:
release:
types: [published]

Looks like I'm running into this

@peter-evans
Copy link
Owner

@ldelossa Replied to your issue here: #522 (comment)

tkoskela added a commit to OrderN/CONQUEST-release that referenced this issue May 25, 2023
Tk/ci skeleton

There is an error from `git symbolic-ref HEAD` during the build
```
sed "s/BBB/"`git symbolic-ref HEAD | cut -b 12-`"/" verstr.f90 | sed "s/RRR/"`git describe --tags`"/" >> datestamp.f90
10
fatal: ref HEAD is not a symbolic ref
```
This is because the action runs on a merge commit,  not a branch, as explained in [this issue](peter-evans/create-pull-request#163). I assume parsing the branch name fails, but since this only runs in the GHA runner, I don't think we should mind too much.
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.

3 participants