-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Git checkout: UnboundLocalError: local variable 'remote_head' referenced before assignment #5504
Comments
@ansible ping, this issue is waiting for your response. |
I am also facing this |
+1, everything has suddenly stopped working... |
Also having this issue. Code:
Error:
This has a 100% failure rate. |
Also having this issue |
This issue also affects 2.2.0 and 2.3.0, but does not affect 2.1.2.0. |
Can reproduce this 100% of the time when |
Also having this issue. |
For those that need a quick fix, you can find the git.py in the ansible source and remove the "after=remote_head".
|
@solomongifford Thanks for the quick fix! Here's hoping for a patch in-release soon! |
@solomongifford Thanks for the quick-fix, but I honestly can't find the file... Where should it normally be located? |
@svenfinke The file (for me) is located here I think - /Library/Python/2.7/site-packages/ansible/modules/core/source_control/git.py @solomongifford There are many instances in the file of "after=remote_head" - you suggest to remove them all? |
@svenfinke and @wasimkham If you run
I edited line 994 in /usr/lib/python2.7/dist-packages/ansible/modules/core/source_control/git.py # from
result.update(changed=True, after=remote_head, msg='Local modifications exist')
# to
result.update(changed=True, msg='Local modifications exist') This change gets me around the problem. Not sure if it's correct, but it seems pretty benign, and I think it's what @solomongifford is referring to. |
This change fixes the following issues encounter with the last version of ansible: * Unable to find '...' in expected paths. Relative role path are not supported anymore, use absolute path instead. * ansible/ansible-modules-core#5504 broke git module when force is used. Apply dirty patch in the meantime. Change-Id: Iac77c2b7d423a63fec75ea569b046ade06d2d2fb
@wasimkham: @BenEinwechter is correct - its just the one in the snippet that I pasted in the comment above. Thats the only one that needs to be removed. @svenfinke: @wasimkham is correct - /path/to/your/python/site-packages/ansible/modules/core/source_control/git.py |
I got affected by this as well with force=yes |
Is there a workaround for this? Maybe like - downgrading the ansible git module? |
@soichih See my comment above for a temporary workaround: #5504 (comment) |
+1 for a fix |
FYI, there is a PR for this: #5505 |
+1 In our case: first run (two current django deploys) it fails, then the 2nd run works fine. |
Just got bit by this. Looks like local modifications to the git repo on the server are the triggering factor for us. |
+1 just hit this after upgrading to 2.2 |
+1 |
@ansible, ping. This issue is still waiting on your response. |
Fix provided by #5505 works 👍 |
Thanks for the workaround @BenEinwechter, that will keep me moving whilst we wait for an official fix. FWIW, installed with homebrew on OSX, I had to modify:
|
For me this is a pretty critical fix, me and all of my team literally cannot update and have to always make sure we're using 2.1.x.x until the fix is in release. Any chance we could get an ETA on this? |
such a critical bug like this, affecting git replication platforms, may be fixed as soon as possible. |
Same issue here, applied the @BenEinwechter 's workaround for now. |
I'm also facing this issue. Worked with ansible 2.1 but failed on 2.2 |
We're also affected and thus our whole development team has problems when provisioning their VMs. Please provide a fix as soon as possible, thank you! :) |
Also seeing this, #5504 (comment) seemed to fix it. |
+1 on Ansible 2.3 |
This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo. |
to bypass this bug: ansible/ansible-modules-core#5504
An alternative workaround that I have found is simply to retry the task, and it succeeds on the second pass. e.g. - name: force pull git on repo with changes
git:
repo: git@bitbucket.org:your-user/your-repo.git
dest: "{{ commit_dir }}"
version: "{{ commit }}"
force: true
register: git_deploy
until: git_deploy|succeeded |
Also seeing this, #5504 (comment) seemed to fix it. |
There are many features I can't use because of this ugly bug.. I hope this will be fixed in the next version. |
This should be fixed by: ansible/ansible#19057 If someone would care to test this against a checkout of either devel or the stable-2.2 branch to confirm it has been taken care of that would be great! Otherwise, I'll close this as fixed in a few days. needs_info |
Possible workaround when "force: true" is required:
|
- Update playbook to make ansible-lint . return a zero exit status - Moves previous commits from a playbook into the structure for a role - Sets some role defaults and raises errors when variables are not set - Applies workarounds for git clone error that appeared when version was defined (version is defined so ansible-lint passes) See Also: - ansible/ansible-modules-core#5504 - ansible/ansible#19057
- Update playbook to make ansible-lint . return a zero exit status - Moves previous commits from a playbook into the structure for a role - Sets some role defaults and raises errors when variables are not set - Applies workarounds for git clone error that appeared when version was defined (version is defined so ansible-lint passes) See Also: - ansible/ansible-modules-core#5504 - ansible/ansible#19057
This change fixes the following issues encounter with the last version of ansible: * Unable to find '...' in expected paths. Relative role path are not supported anymore, use absolute path instead. * ansible/ansible-modules-core#5504 broke git module when force is used. Apply dirty patch in the meantime. Change-Id: Iac77c2b7d423a63fec75ea569b046ade06d2d2fb
ISSUE TYPE
COMPONENT NAME
git
ANSIBLE VERSION
CONFIGURATION
pipeline = True + related ControlPath etc
OS / ENVIRONMENT
Linux
SUMMARY
Git checkout fails randomly. Seems like a race condition.
STEPS TO REPRODUCE
Have a step:
EXPECTED RESULTS
OK
ACTUAL RESULTS
Randomly get (about 50% of the time):
The text was updated successfully, but these errors were encountered: