airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.34k stars 296 forks source link

<SNR>116_run_diff error #106

Closed sunaku closed 10 years ago

sunaku commented 11 years ago

Hello, I get the following error every few seconds (even when not doing anything):

Error detected while processing function GitGutter..<SNR>116_run_diff:
line   13:
E484: Can't open file /tmp/vqLwd5h/18
Press ENTER or type command to continue

This only started happening after upgrading this plugin in the last few days.

Thanks for your consideration. :sweat_smile:

hlecuanda commented 11 years ago

I can confirm having the same issue.

Apparently there is an issue in the realtime logic, where a temp file is being created, perhaps when running the diff command.

I remember having a similar problem with vimscript a couple of years ago, and i solved it by explicitly naming a file to dump temp data, and not expecting vim to handle it. if i can get around to it, i'll try to fix it here ;)

I'm working with MacVim 7.4, on MacOS 10.7.5

I got around it by disabling realtime mode. Eager is good enough for me =) just add

let g:gitgutter_realtime = 0

somewhere in your .vimrc

sunaku commented 11 years ago

Awesome! Adding that line to my vimrc fixed the problem for me. Thanks! :cake:

lstor commented 11 years ago

I'm getting this as well, on Windows 7 with Vim 7.4.

airblade commented 11 years ago

What version of git are you all using?

@hlecuanda That's interesting to hear. Is Vim known to have a problem with files for temp data?

beepscore commented 11 years ago

I saw this problem too after updating spf13-vim and doing BundleInstall. Using OS X 10.8.4 and MacVim 7.4 (70) with Vim 7.4 hlecuanda's suggested fix worked for me. I made pull request above to spf13. Thanks.

airblade commented 11 years ago

@beepscore What version of git are you using?

beepscore commented 11 years ago

@airblade git version 1.7.12.4 (Apple Git-37)

airblade commented 11 years ago

@beepscore In that case this is a different problem from #105. Useful for me to know, thanks.

lstor commented 11 years ago

@airblade I'm using git version 1.8.3.msysgit.0 (on Win7 with Vim 7.4)

kenips commented 11 years ago

git version 1.8.3.4 / Vim 7.4 / Mountain Lion - pretty much latest on brew.

jimhester commented 11 years ago

The command which fails is

Calling shell to execute: "(pushd "/currentdir" && git rev-parse > /dev/null 2>&1) >/tmp/vx3LqTA/31 2>&1"
                                                                        ls-files --error-unmatch > /dev/null 2>&1 "/currentdir/file") >/tmp/vx3LqTA/32 2>&1"
                                                                    diff -U0  <(git show :./file) -  | grep -e "^@@ ") < /tmp/vx3LqTA/33 >/tmp/vx3LqTA/34 2>&1"

Not sure why all three commands are being concatenated together, but I think that is the source of the problem.

sunaku commented 11 years ago

This looks fishy. Why is /tmp/vx3LqTA/33 being fed into the stdin of diff(1) ?

diff -U0  <(git show :./file) -  | grep -e "^@@ ") < /tmp/vx3LqTA/33 >/tmp/vx3LqTA/34 2>&1"

Remove the < and I think we'll have something that works:

diff -U0  <(git show :./file) -  | grep -e "^@@ ") /tmp/vx3LqTA/33 >/tmp/vx3LqTA/34 2>&1"
airblade commented 11 years ago

@sunaku It's diffing the file as it is in git (git show :./file via process substitution) with the contents of the Vim buffer, via stdin.

Vim sends the buffer's contents to diff's stdin by writing the contents to a temporary file and redirecting that temporary file to the diff. Hence the - as diff's second file argument.

In VimL this is achieved by passing the buffer's contents as the second argument to system(). The plugin does it here.

airblade commented 11 years ago

@beepscore @kenips I'm also on OS X 10.8.4, MacVim 70 with Vim 7.4, git v1.8.2.3, diff (GNU diffutils) v2.8.1 – and it works for me. Strange that it doesn't work for you...I wonder what's different?

airblade commented 11 years ago

@jimhester Weird. Not sure why that's happening for you.

jimhester commented 11 years ago

Just tracked this down, it is happening because my default shell is zsh, I would imagine it is the same problem with the others as well. If I put set shell=/bin/bash in my vimrc the error goes away. Not sure what part of the commands are not zsh compatible, but that is what is wrong.

airblade commented 11 years ago

@jimhester Good catch. If you search the issues for "zsh" you'll see related problems have come up before; I didn't realise this was also a shell problem.

I'd like the plugin to work on as many shells as possible and in fact I thought it did work on zsh. I think I'll need to go through the plugin's commands with a fine-toothed comb checking for shell compatibility.

beepscore commented 11 years ago

I'm using zshell. @jimhester fix works for me also. Good sleuthing, people!

To test, in my .vimrc, I deleted hlecuanda fix let g:gitgutter_realtime = 0 This restored the issue.

Then in .vimrc I added jimhester fix set shell=/bin/bash This fixed the issue.

sunaku commented 11 years ago

@jimhester's fix did not work for me (my shell is already bash and I already set shell=/bin/sh in Vim).

Instead, only @hlecuanda's fix of setting let g:gitgutter_realtime = 0 fixed the problem for me.

sunaku commented 11 years ago

Oops, @jimhester's fix of set shell=/bin/bash fixed the problem for me now. :sweat_smile:

So it seems that both ZSH and plain old POSIX SH are not suitable for GitGutter.

hlecuanda commented 11 years ago

sorry for getting back to you guys late in the game

my default shell is tcsh (yeah i'm a tcsh guy haha),

and the issue is related to vim spawning bash shells no matter what your default shell is. When i had this issue before, a few years ago, any shell commands got their own sub-shell (bash) and redirection in those commands somehow prompted vim to create a temp file. (perhaps vim parses the commands on its own before spawining any shells at all)

of course, these are "secure" temp files, which means they get obliterated when the shell dies. The next part of the command picks up the reference, which no longer exist and thats when the problem shows its ugly head.

I got around it refactoring my code to avoid implicit tmp file creation, by explicity creating a tmp file by name and then using that reference in the next step of whatever processing was necessary. of course, that comes at the price of handling and deleting any tmp files you created, or trusting the OS to later handle them.

maybe

set shell = /usr/bin/env bash

is a better idea (bash is not guaranteed to live in /usr/bin )

dubspeed commented 11 years ago

I had the same issue on Mac 10.8.4, vim 7.3, also using the spf13 set of bundles. Using

set shell=/bin/bash

works for me as well. It seem the default shell is "sh-3.2" where it fails.

gpakosz commented 10 years ago

I'm having the issue with Windows.

The plugin shows the marks correctly. Then when idle, the plugin spits the following errors:

Calling shell to execute: "cd "C:/Users/gregory/.vim" && git rev-parse > /dev/nul l 2>&1 >C:/Users/gregory/AppData/Local/Temp/VIoE0BF.tmp 2>&1"
Calling shell to execute: "cd "C:/Users/gregory/.vim" && git ls-files --error-unmatch > /dev/null 2>&1 "C:/Users/gregory/.vim/.vimrc" >C:/Users/gregory/AppData/Local/Temp/VIoE17B.tmp 2>&1"
Calling shell to execute: "cd "C:/Users/gregory/.vim" && diff -U0  <(git show :./.vimrc) -   <C:/Users/gregory/AppData/Local/Temp/VIiE238.tmp | grep -e "^@@ " >C:/Users/gregory/AppData/Local/Temp/VIoE239.tmp 2>&1"
Error detected while processing function GitGutter..<SNR>57_run_diff:
line   13:
E484: Can't open file C:/Users/gregory/AppData/Local/Temp/VIoE239.tmp

Looks like it can't write to the file...

LeszekSwirski commented 10 years ago

That would be because diff -U0 <(git show :./.vimrc) is not valid cmd syntax, anonymous pipes are a bashism.

sunaku commented 10 years ago

Good point @LeszekSwirski. :neckbeard: I have submitted pull #118 to address that very issue. :cake:

kuznero commented 10 years ago

Please take in this fix for Windows soon :)

airblade commented 10 years ago

This ought to be fixed by c5872cd. Please upgrade and let me know if you still have trouble.

oeuftete commented 10 years ago

This is still kicking around. I can reproduce it reliably by creating a file called foo( or foo) and opening it. I have 'shell=/bin/bash` and vim-gitgutter version is f158fee95e05d3736516784352f5fb5e4127bbf9 .

airblade commented 10 years ago

@oeuftete Thanks for letting me know. It should be fixed in bd2091a.

ashishb commented 10 years ago

I just start getting this issue after doing a "BundleUpdate" 5 minutes back.

airblade commented 10 years ago

@ashishb I've made a couple of changes – would you mind updating and trying again?

ashishb commented 10 years ago

Thanks Andy, it works after update.

Ashish

On Fri, Jan 31, 2014 at 1:10 AM, Andy Stewart notifications@github.comwrote:

@ashishb https://github.com/ashishb I've made a couple of changes - would you mind updating and trying again?

Reply to this email directly or view it on GitHubhttps://github.com/airblade/vim-gitgutter/issues/106#issuecomment-33770894 .

geraldus commented 9 years ago

If I put set shell=/bin/bash in my vimrc the error goes away

Helped for me too! Thank you! BTW I've switched to fish right now. @airblade can you support fish shell as well? (:

airblade commented 9 years ago

@geraldus See #228.

hlecuanda commented 9 years ago

Wow! I didn't realise this issue refused to die after a year and change... in fact, i was surprised to see my own comment way back at the beginning of the thread... i even thought.. "hey that guy's avatar looks just like my own.... and on top of it; writes about the issue like he's full of himself... hey, wait.... vim temp files, yeah, i remember having something to do with them back in the day.... haha

sorry about the babble... i was just amazed by my sudden perception of the passage of time...

airblade commented 9 years ago

@geraldus vim-gitgutter now supports the fish shell (0ca15c8).