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

git error: "fatal: BUG: disabling cancellation: Invalid argument" #3351

Open
neclepsio opened this issue Feb 6, 2018 · 51 comments
Open

git error: "fatal: BUG: disabling cancellation: Invalid argument" #3351

neclepsio opened this issue Feb 6, 2018 · 51 comments

Comments

@neclepsio
Copy link

neclepsio commented Feb 6, 2018

Since some updates, when I try to use git pull I get the error fatal: BUG: disabling cancellation: Invalid argument. I use a proxy.

@neclepsio neclepsio reopened this Feb 6, 2018
@neclepsio
Copy link
Author

Reinstallation seemed to fix, but the problem reappeared and this time reinstallation doesn't fix. The problem is present even if the proxy configuration is deleted.

@neclepsio neclepsio reopened this Feb 6, 2018
@pal1000
Copy link
Contributor

pal1000 commented Feb 6, 2018

Tracked upstream as git-for-windows/git#1481.

@neclepsio
Copy link
Author

The error message is different. Are you sure it's the same problem?

@pal1000
Copy link
Contributor

pal1000 commented Feb 6, 2018

Yes the error messages are related. Differences are only made by presence and absence of proxy and probably Git for Windows running in a slimmer MSYS2 environment.
The best we can do is go back to 2,16.1.1.

@henkman
Copy link

henkman commented Feb 22, 2018

Same problem here with git version 2.16.2. pull, push, log all give the error message
"fatal: BUG: disabling cancellation: Invalid argument".
If I use the msys2.exe shell they work but in cmd.exe the error message occurs

@pal1000
Copy link
Contributor

pal1000 commented Feb 23, 2018

I can't repro. I don't know what happens at your end.

@henkman
Copy link

henkman commented Feb 23, 2018

Just found out that it works in cmd.exe if you have msys2.exe running but not using it. As soon as you close the msys2 shell - boom it does not work anymore.
So there is some interprocess communication involved with either bash.exe or mintty.exe

@sroller
Copy link

sroller commented Mar 23, 2018

It seems the problem was solve upstream. Will there be a new package for msys2 available? I'm running 2.16.2 (64bit) and I'm still having the described problem.

@ankostis
Copy link

Just found out that it works in cmd.exe if you have msys2.exe running but not using it. As soon as you close the msys2 shell - boom it does not work anymore.

Same on me with MSYS2, git-2.17.0. I need to have msys2 or mingw64/32 windows open, or certain git commands (ie git log, diff ) fail with the above error. But git --version or git status add run fine.

Very strange.

@pal1000
Copy link
Contributor

pal1000 commented Apr 25, 2018

@sroller, 2.17.0 is available but is not posted here for some reason. A more direct link would be:
https://github.com/git-for-windows/git/releases/latest.

@ankostis
Copy link

I note that the problem happens also with older git version 2.15.0.

@axbender
Copy link

Any news on this? This bug keeps nagging me even in git 2.18.0. The same constellation (my MSys2 installation is run from a USB drive) works with Windows 7 while it fails in Windows 10 (1709).

@dmytrol
Copy link

dmytrol commented Sep 11, 2018

In my case this was caused by a path to a different instance of msys64 preceding a path to the Git binaries in the PATH environment variable. Removing the path to msys64 fixed the problem.

@rcorvus
Copy link

rcorvus commented Sep 11, 2018

@dmytrol's solution fixed it for me, I removed the msys64 from PATH and after rebooting, git works again.

@neclepsio
Copy link
Author

dmytrol's solution DID NOT fix for me, as the path was right.

In my case as henkman writes it works in cmd.exe if msys window is open (https://github.com/Alexpux/MINGW-packages/issues/3351#issuecomment-368065275).

@Anujay-Saraf
Copy link

Hi All,

Downgrading the version of git to 2.16.1 helps this issue, one can downgrade the Git version by downloading and installing the same in Windows.

link;- https://github.com/git-for-windows/git/releases/tag/v2.16.1.windows.1

Regards,
Anujay

@axbender
Copy link

axbender commented Jul 7, 2019

@wangxuesong29
Could you please detail on what you mean exactly?

@axbender
Copy link

axbender commented Jul 8, 2019

@wangxuesong29

Hi!
Unfortunately this doesn't work on my end... Also, please consider:
a) Git works w/o problems on Windows 7 using the exact same configuration (USB drive).
b) Adding an EXE to your PATH environment variable is useless (it's no path); the system will not honor it (lest your "msys2.exe" is a path... ;-).

Once I read something about Windows 10 having problems with the relocation addresses of MSys2 executables. I followed the recipe, but it wouldn't work either. I'm still at loss...

@ankostis
Copy link

Still we have not isolated the root-cause of the issue, and why one installation affects the other.

@axbender
Copy link

No double installation here, just MSys2's git...

@neclepsio
Copy link
Author

Just msys2 installation for me, and it doesn't work from any shell if msys2 shell is not open. But if I open a msys2 shell, it works even from every shell.

@gbrunick
Copy link

I see the same behavior as @neclepsio. git fetch works if I have a Mintty Bash window open (MSYS2 or Ming2-w64 64bit), and fails with

> git fetch
BUG: run-command.c:519: disabling cancellation: Invalid argument

otherwise. I'm on Windows 10, I use a proxy as well, and:

> git --version
git version 2.24.0
> which git
/usr/bin/git

@4sfaloth
Copy link

4sfaloth commented Feb 5, 2020

I have no clue about the underlying causes, but if it helps someone I was facing this issue (fatal: BUG disabling cancellation: Invalid argument when trying to run git branch --merged) and it was fixed by following @wangxuesong29's suggestion (ie: removing c:\msys64\usr\bin from path). Not sure what the consequences of this for other applications might be though...

@sroller
Copy link

sroller commented Feb 6, 2020

Are you sure there is no other git.exe in your path?

@4sfaloth
Copy link

Are you sure there is no other git.exe in your path?

I cannot guarantee that. I can only say that I was experiencing the fatal: BUG described above when trying to run git branch --merged and that it was fixed by removing c:\msys64\usr\bin from the path as per @wangxuesong29 suggestion

@axbender
Copy link

No "double" git.exe here; however, in my MSys2 installation there's a hard link between /usr/bin/git.exe and /bin/git.exe, and there's a /mingw64/bin/git which calls /usr/bin/git. I renamed/copied/... several combinations but the error remains (other than in Windows 7)

@StarWolf3000
Copy link
Contributor

No "double" git.exe here; however, in my MSys2 installation there's a hard link between /usr/bin/git.exe and /bin/git.exe, and there's a /mingw64/bin/git which calls /usr/bin/git. I renamed/copied/... several combinations but the error remains (other than in Windows 7)

There's no /bin directory in MSYS2.

@axbender
Copy link

Hm, I'm tempted to say "you're wrong" (as I do have a /bin and a /usr/bin directory), but may be this is the core of the problem. Here both directories are hardlinked. How would I get rid of this association? Just rm -rf /bin seems to be too dangerous...

@axbender
Copy link

axbender commented Feb 13, 2020

Addendum: /bin does not exist outside of MSys2 (e.g. using Windows Explorer), but is visible inside of mintty.

@StarWolf3000
Copy link
Contributor

According to the mount command, /bin is mounted from /usr/bin so doing the rm -rf /bin would kill your MSYS2 environment, except for bash.exe, mintty.exe, rm.exe and several dlls.

@axbender
Copy link

Interesting. Who would mount /bin to /usr/bin? Checked /etc/fstab => nope.
Any idea?

@axbender
Copy link

Update: Found this in github/MSys2:

Alexx83 - 2014-06-24

Now we remove mounting /usr to / in MSYS2.
Today we switch to new MSYS2 files layout. Now all MSYS2 packages installing into real /usr prefix.
Root directory contains only sysconfig directories: etc, var, tmp, home.
For mingw-w64 packages nothing changed - they installing as usual in to /mingw32 and /mingw64 folders.
But we still have one virtual mount directory - for compatibility reasons we mount /bin to /usr/bin.

@StarWolf3000
Copy link
Contributor

StarWolf3000 commented Feb 14, 2020

I think that's still done to keep high compatibility with Cygwin, which MSYS2 is based on.

@axbender
Copy link

Any news on the original topic?

@Gei0r
Copy link

Gei0r commented May 5, 2020

The problem still exists when running git pull from the windows cmd shell.

git version 2.26.2
BUG: run-command.c:519: disabling cancellation: Invalid argument

Curiously, if a msys2 shell (C:\msys64\usr\bin\bash.exe in my case) is running, git pull also works from a cmd shell.

@StarWolf3000
Copy link
Contributor

Still cannot reproduce any problems with Git. I can use it just fine from both CMD and MSYS2 and MINGW shells.

@Gei0r
Copy link

Gei0r commented May 5, 2020

Is there a way I can produce more debugging information on this problem?

@beliaev-maksim
Copy link

hey guys,
once you install MSYS2 you automatically add env variable that points to bin of MSYS. After upgrade of git you may get your git installation in PATH env var be later in the list.

Once git is called in terminal, shell looks for executable in path and finds MSYS2 git first.
Just edit your environment variables the way, that first comes "git" and then "MSYS2"
image

@duocang
Copy link

duocang commented Apr 6, 2021

I have deleted my old answer.

Simple answer: There are two git.exe, they fight.

  • You installed one
  • one comes with msys.

What to do?

@beliaev-maksim
Once git is called in terminal, shell looks for executable in path and finds MSYS2 git first.
Just edit your environment variables the way, that first comes "git" and then "MSYS2"

@axbender
Copy link

axbender commented Apr 6, 2021 via email

@kimim
Copy link

kimim commented Apr 22, 2021

This error happens also when I invoke git in emacs eshell:

Welcome to the Emacs shell

~/kimim-emacs $ git pull
BUG: run-command.c:520: disabling cancellation: Invalid argument
~/kimim-emacs $ which git
c:/msys64/usr/bin/git.exe
~/kimim-emacs $ git version
git version 2.31.1

@rwreay
Copy link

rwreay commented Jun 25, 2021

Same issue: Win10 Windows Command Prompt, git pull and git clone fail in command prompt unless an instance of an MSYS shell is running. There is only one instance of git on this machine.

Possibly relevant, Strawberry Perl and Miniconda are installed and in the path.

[...]>git pull
BUG: run-command.c:520: disabling cancellation: Invalid argument

[...]>where git
C:\msys64\usr\bin\git.exe

[...]>git version
git version 2.32.0

@beliaev-maksim
Copy link

@rwreay
I am not sure that you can use MSYS git in Win Shell. You have to use MSYS git in MSYS console.

otherwise install git for windows in parallel and ensure proper paths in env vars (see my previous message)

@Biswa96
Copy link
Member

Biswa96 commented Jun 26, 2021

I am not sure that you can use MSYS git in Win Shell.

Yes, you can. MSYS2 programs are like other Win32 programs, nothing special. But you have to make sure that the %PATH% is not mixed up with other toolchains, as rwreay mentioned strawberry perl etc.

@kimim
Copy link

kimim commented Jun 27, 2021

Same issue: Win10 Windows Command Prompt, git pull and git clone fail in command prompt unless an instance of an MSYS shell is running. There is only one instance of git on this machine.

Thank you for providing a workaround. I use git in Emacs/magit. When a MingW64 window is open, git works fine also.
I used to think it is a random problem, that git works fine sometimes and gets error randomly..

@rwreay
Copy link

rwreay commented Jun 28, 2021

But you have to make sure that the %PATH% is not mixed up with other toolchains, as rwreay mentioned strawberry perl etc.

This problem occurs when there is only msys2 directories in my path.

[...]>echo %PATH%
C:\msys64\mingw32\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin

[...]>git pull
BUG: run-command.c:520: disabling cancellation: Invalid argument

[...]>echo starting MSYS shell...
starting MSYS shell...

[...]>git pull
Already up to date.

@ryanavella
Copy link

I'm having the same issue. Strangely, some of the git subcommands work if I redirect the output to a temporary file. For example:

C:\tmp\repo>git log
BUG: run-command.c:519: disabling cancellation: Invalid argument

C:\tmp\repo>git log > test && type test
commit a78d08b9bdb401a5ddfb5bea97240af7c49e9795
Merge: 482afb59 fd82aa28
...

@sansalinas
Copy link

In my case, just open msys2_shell.cmd previosly and it works :S

@malkia
Copy link

malkia commented Jan 8, 2022

I was also looking for solution, and what @sansalinas ^^^ proposed worked for me too, though I wanted to avoid the window being visible, and launched mintty (which seems to launch bash, and probably that made it working) - e.g. in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup (or per user in C:\Users[User Name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) I've added a batch file that does this: c:\msys64\usr\bin\mintty.exe -w hide

@jonas-fsr
Copy link

Hey all,
so in my case the error appeared after I upgraded my Intellij IDE to the latest version (2022.1.3) which appeared not to match the latest version of git and git toolbox plugin. The error vanished after downgrading the IDE back to version 2021.3.3.

@ryanavella
Copy link

I moved C:\msys64\usr\bin to the very top of my PATH, but that didn't quite fix it.

However, the symptoms disappeared after updating to git-2.42.0.

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

No branches or pull requests