Ansible: git clone fails with "fatal: Out of memory, realloc failed" - windows

I'm using Ansible with a Windows host (VM).
I'm trying to git clone a large content (actually using git lfs). It's around 15Go in total
I'm using git for windows (https://github.com/git-for-windows/git/releases/tag/v2.37.2.windows.2).
I have the following Ansible task:
- name: Clone repository
ansible.windows.win_command: >
<path/to/git.exe> clone <git-repo>
The problem is that it always fails with the error:
fatal: Out of memory, realloc failed
I tried to increase the windows VM memory, or to play with git config settings, as explained in several posts, for example:
remote: fatal: Out of memory, realloc failed on git push with post-receive hook
git out of memory on checkout
https://community.atlassian.com/t5/Bitbucket-questions/Message-erro-quot-fatal-Out-of-memory-realloc-failed-quot/qaq-p/894048
But none of these solutions work for me. It always failed at the same points:
"Filtering content: 48% (440/902), 2.11 GiB | 6.70 MiB/s",
"fatal: Out of memory, realloc failed",
"Error downloading object: xxxxxxx: Smudge error: Error reading from media file: write /dev/stdout: The pipe is being closed.: write /dev/stdout: The pipe is being closed.",
"",
"Errors logged to 'xxxx.log'.",
"Use `git lfs logs last` to view the log.",
"warning: Clone succeeded, but checkout failed.",
"You can inspect what was checked out with 'git status'",
"and retry with 'git restore --source=HEAD :/'"
The weird things is that this error only happen using Ansible. If I connect to the VM and manually run exactly the same git clone command, everything goes well.
Do you have any idea to help me? Thanks

I experienced the same behaviour in a similar situation. I was trying to do a reference clone for a repository that's originally over 100GB and also contains LFS files. The out of memory was only seen when trying to execute the clone via Ansible's win_shell.
What worked for me was using the Ansible win_shell module and increasing the MaxMemoryPerShellMB to a large enough value. I figured out the value by doubling the memory until it was larger than the default value but smaller or equal to the actual memory limits of my machine.
Including a snippet of what tasks you'll need to resolve this problem successfully:
---
- name: Increase MaxMemoryPerShellMB
win_shell: 'Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB <value>'
- name: Clone the repository
win_shell: '<git clone command>'
args:
executable: cmd
Additionally, if it's possible for your usecase, I'd recommend skipping the clone of LFS files and fetching the files that you need afterwards. Refer to the git config commands in 'How to clone/pull a git repository, ignoring LFS?'. It's subtle but the answer seems to indicate that GIT_LFS_SKIP_SMUDGE variable is obsolete for Windows. I'm still trying to find a proper piece of documentation for this.
I hope this helps you!

Related

GitHub Error: RPC failed; curl 92 http/2 stream 0 was not closed cleanly: CANCEL (err 8) | send-pack: unexpected disconnect while reading sideband

I am working on a project with a GitHub repo. I've been able to "add *", "commit" and "push" everything without a problem in the last 3 months. Now I downloaded a dataset containing about 12 GB of data and I have created a new folder for it.
I made some minor changes to the file that was already in the repo (for 3 months) and did "add *", "commit" and "git push".
After counting and compressing the objects, Git Bash throws up this error:
GitHub Error: RPC failed; curl 92 http/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
...
fatal: the remote end hung up unexpectedly
Everything up-to-date
This is happening probably while writing the objects.
I have tried the following:
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
git config --global http.postBuffer 100000000
git config --global https.postBuffer 100000000
After the latest attempt with all of the solutions mentioned above, this additional error was thrown after getting to 50% of writing the objects:
remote: fatal: pack exceeds maximum allowed size
A screenshot of the error on Git Bash
So, my question is:
1. Why is this happening?
2. How can I work around/solve this problem and successfully push my current workspace onto GitHub?
I solved this problem by bypassing it with this tutorial:
https://githowto.com/removing_commits_from_a_branch
ATTENTION: Remember to make a copy of your code before proceeding. You can still go back since you aren't deleting commits but it's annoying when you have to follow the tutorial twice.
ALSO: The git hist command is an alias. This is the one I copied:
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
LINK: https://gist.github.com/ecasilla/9669241
1. Why is this happening?
Because you are trying to push a large file. (12 GB dataset)
2. How can I work around/solve this problem and successfully push
my current workspace onto GitHub?
You can use Git Large File Storage that replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com

Git clone a little bit at a time or other solutions

I'm working on a Windows machine, from git bash.
We recently moved our project from a TFS server to a git repo on the same server. As far as I know, this was all done in one commit. I am remote.
When I run git clone <url> the clone will start, but at some seemingly arbitrary point (a different one every time), it will fail with:
error: RPC failed; curl 56 Recv failure: Connection was reset
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
I was thinking perhaps if there were a way to clone the repo a few files at a time, that would work. It seems unlikely that such a solution exists. I have tried increasing the http.postBuffer to 157286400, and I do not think switching to ssh is an option for us currently. A shallow clone is unhelpful, as there has only been one commit. These are the solutions I've seen elsewhere. Any help would be greatly appreciated.

git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

I'm having trouble cloning a repo on git. I've been trying for to days and have tried quite a few solutions (in most the problem was slightly different but seemed to apply) but nothing has done anything to make a difference.
I've tried switching off the anti-virus and firewall but that didn't help.
I've also tried uninstalling and reinstalling the network adapter drivers (and restarting the computer) and that didn't work.
From what I understand it's a network issue somewhere as the remote server keeps hanging up but I'm not managing to get anywhere with the issue.
Using git clone -v --progress seemed to give the same output as git clone.
Output from git clone -v --progress https://github.com/mit-cml/appinventor-sources.git
Cloning into 'appinventor-sources'...
POST git-upload-pack (gzip 1425 to 774 bytes)
remote: Counting objects: 41649, done.
remote: Compressing objects: 100% (7/7), done.
error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
I've now tried increasing the buffer again
git config --global http.postBuffer 1048576000
but still nothing.
I'm following the solution from The remote end hung up unexpectedly while git cloning for troubleshooting.
I resolved the same problem by this:
git config http.postBuffer 524288000
It might be because of the large size of repository and default buffer size of git so by doing above(on git bash), git buffer size will get increase.
I had the same issue, and I have solved it by changing my net connection.
In fact, my last internet connection was too slow (45 kbit/s).
So you should try again with a faster net connection.
I had the same problem, and #ingyhere 's answer solved my problem .
follow his instructions told in his answer here.
git config --global core.compression 0
git clone --depth 1 <repo_URI>
# cd to your newly created directory
git fetch --unshallow
git pull --all
you need to increase the buffer size (it's due to the large repository size),
so you have to increase it
git config http.postBuffer 524288000
Althought you must have an initializd repository, just porceed as the following
git init
git config http.postBuffer 524288000
git remote add origin <REPO URL>
git pull origin master
...
git config --global http.postBuffer 524288000
Work in my case - AWS code commit
This happens when you push first time without net connection or poor net connection.But when you try again using good connection 2,3 times problem will be solved.
I have tried "git init" and it worked like charm for me.
I got it from the link Git push error: RPC failed; result=56, HTTP code = 200 fatal: The remote end hung up unexpectedly fatal
(based on anser from Hakan Fıstık)
You can also set the postBuffer globally, which might be necessary, if you haven't checkout out the repository yet!
git config http.postBuffer 524288000
Uninstalling(version: 2.19.2) and installing(version: 2.21.0) git client fixed the issue for me.
just Disable the Firewall and start again. it worked for me
It could be an issue with your network (i.e. not an issue with any of your git configs, firewall, or any other machine settings). To confirm this, you could test the following:
See if this issue persists on the same network on different machines (this was true for me).
Try running the problematic git command (for me it was git pull) on a different network and see if it works. I brought my desktop over to a friend's and confirmed that the command did indeed work without any modifications. I also tested the command from my laptop on an open network nearby and the command also started suddenly working (so this was also true for me)
If you can confirm #1 and #2 above, it may be time to schedule an appointment with a technician from your ISP. I have fiber internet in a fairly newish building and when the technician arrived they went to my building's telecom room and switched my internet port. That somehow seemed to fix the issue. He also let me know that there were other issues at large going on in my building (so it could have nothing to do with your machine or things in your control!).
If that fails, maybe consider switching internet providers if that's an option for you. Else, just keep calling your ISP to send in more and more senior technicians until it gets resolved.
I'm hoping nobody actually has to resort to what I did to find the problem.
tl;dr: Give your ISP a call as the issue could be one with your network.
All these tips did not work for me,
what worked was cloning over ssh rather than http
Following steps helped me to fix this issue,
Solution 1:
git checkout master
git pull
git checkout [you current branch]
git pull
You can also set git config http.postBuffer 524288000 to increase the network buffer
Solution 2:
Sometimes it happens when you are cloning your repo using VPN and it fails to verify the SSL
Try this out it may help:
git config http.sslVerify "false"
I had the same issue and found out the problem was with my internet speed, after getting on a better connection the problem was solved solved.
Before cloning just run "git init". It will create local .git and it will allow for clone.
If you have VPN opened, close and try it again.
It's mentioned as SSL_ERROR_SYSCALL, errno 10054.
To resolve this SSL issue I went to .gitconfig file (which is located in c drive in my desktop) I changed sslverify to false and added my username and email id.
sslVerify = `false` //make sslVerify as false
[user]
name = `***<Enter your name>**`
email = `**<Email Id>**`
I had the exact same problem while trying to setup a Gitlab pipeline executed by a Docker runner installed on a Raspberry Pi 4
Using nload to follow bandwidth usage within Docker runner container while pipeline was cloning the repo i saw the network usage dropped down to a few bytes per seconds..
After a some deeper investigations i figured out that the Raspberry temperature was too high and the network card start to dysfunction above 50° Celsius.
Adding a fan to my Raspberry solved the issue.
What I did is moved the dependencies list to the end of
#Pods for <app>
In Podfile. Like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target '<app>' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for <app>
target '<app>Tests' do
inherit! :search_paths
# Pods for testing
end
target '<app>UITests' do
inherit! :search_paths
# Pods for testing
end
pod 'Firebase/Core'
pod 'Firebase/Database'
end
In my case, its something wrong with my DNS server, after i add a new github.com record in the hosts, the problem solved.
13.114.40.48 github.com
1. Go to https://gitforwindows.org
2. Download
3. Install (no need to uninstall)
4. That's it! No more error: RPC failed; curl 56 OpenSSL SSL_read: No error
I too have faced this issue today. I have tried all the options shared in this thread but I was still having the issue.
I tried cloning after connecting to my corporate VPN and cloning got completed successfully. So, guys it might have to do with your local firewall policy. Factor in that as well :)
This is what works for me.
git config --global http.sslVerify "false"
For me, git config --global http.postBuffer 524288000 alone did not fix it, I had to run git config --global core.compression 0 as well.
this issue is resolved by cloning using SSH key.
first of all set the ssh key and then add it to your git/github account. and then try to clone using ssh instead of using http.
in my case this solved my problem.
i tried all the other solution including increasing the buffer size, changing the git version, etc.
none of these solution works in my case.
I've tried postBuffer, core.compression and --depth 1, nothing is working perfectly, I mean sometimes, I could clone but most of the time, I got the same error. For me, it got worked out by cloning using SSH url. You can follow below steps to clone in ssh way
create ssh key
create .ssh folder in your user directory (C:\Users\Rence Abishek\) and inside .ssh folder, create a file named id_rsa
Open your terminal from user dir and execute below commands to create ssh private and public key
ssh-keygen -t rsa -b 4096 -C "renceabishek#abc.com"
press y to override existing file i.e id_rsa and not require to give passphrase, just hit enter
eval $(ssh-agent -s)
ssh-add ./.ssh/id_rsa
copy ssh key to your git version control(gitlab,bitbucket,github..etc)
Execute cat ./.ssh/id_rsa.pub command in terminal to get public key in console, now copy that and go to your GIT version control setting and add your copied public key.
Github -> click on your profile(top right cornor) -> setting -> SSH and GPG Keys -> New SSH Key button
clone repo
Now clone using ssh url git clone YOUR_SSH_URL
try this,
git init first/reinitialize
then, global http.postBuffer 157286400
after that, just set/add ur remote like before
add, commit, push. this solves mine
For me the issue was with my wifi extender. When I connect directly to my wifi without using extender, it started working.

Cannot clone GIT repository on network drive

Using Windows 7, we have a bare GIT repository set up on a network drive so that multiple users can pull/push from it. I am able to create a new working repo on my local and multiple other networked drives. However, when I try to clone a new working repository on the same network drive (different folder) , it fails.
Using TortoiseGIT, after I right-click and choose "GIT Clone", put in all of the necessary paths to my bare repo (the new working repo is already filled in) and hit ok, I get the following error:
Cloning into 'R:\path\to\new\repo'... done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistent object 5d2164db2c61efc7a5598f6ff75ed3fbbb12456e
fatal: Cannot update the ref 'HEAD'.
fatal: The remote end hung up unexpectedly git did not exit cleanly (exit code 128)
and it fails to create the repo. It does however build the new folder & ".git" subfolder structure.
It's not a r/w permissions issue because I can r/w any other files, but just cannot seem to create this newly cloned repo. My co-worker cannot either. Even if I got to another folder on the network drive, I still cannot clone the repo successfully. Surprisingly, if I just copy/paste a repo I created in another location, then manually do a "pull", it works and updates successfully.
Any ideas on what to try next? Obviously I've Googled "exit code 128" and "cannot update the ref 'HEAD'" but cannot find a solution to my issue. It's probably something really simple that we are overlooking, but we're just getting started with GIT and this is really causing us headaches...
UPDATE: I just noticed that when I do a manual pull from GIT to my "copy", it is doing a Fast-Forward. Maybe this provides some additional clues?
From R:/path/to/repo
* branch master -> FETCH_HEAD
Updating 5d2164d..d75bdb7
Fast-forward
Files.py | 3 +++
1 file changed, 3 insertions(+)
Success
Git might be trying to do some smart stuff with hardlinks that fails on the network drive. Try using git clone --no-hardlinks /r/path/to/my/repo or git clone file:///r/path/to/my/repo
Please do this via command line in msysgit
git clone /r/path/to/my/repo /r/some/other/path
Further, I would recommend using git from the command line as it is a tool that was designed to be used from the command line. You will be able to find more help, faster, with any issues that come up for you.

Git fetch github: Index-pack failed

When running the command git fetch github , I get the following error:
fatal: write error: Broken pipe93), 23.23 MiB | 635 KiB/s
fatal: index-pack failed.
I then get a "git.exe has stopped working" error message while Windows attempts to find a solution to the problem.
Running *GIT_TRACE=1 git fetch github* doesn't give any additional details.
Note: I can perform a git fetch github [branch name] directly and that works without error
When I try "Repository > Compress Database" in Git Gui, I get "Error: Command Failed". I get the same error when I try "Repository > Verify Database".
How do I get around this? It's almost like my local repo is corrupt.
System Info
*Git Bash: 1.7.4-preview20110204
Windows 7 64-bit*
Couple of options:
check if the problem persists in a new local repo (so, after re-cloning your GitHub repo)
check if raising the postBuffer size can alleviate the problem
git config --global http.postBuffer 524288000
(as mentioned in "The remote end hung up unexpectedly while git cloning")

Resources