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.35k stars 296 forks source link

OS X El Capitan error: "E212: Can't open file for writing" after Vim window open for long time #395

Closed AaronM04 closed 7 years ago

AaronM04 commented 7 years ago

Hi, I noticed a problem with gitgutter that appears on Mac OS X after the Vim window is open for 15 days or so:

Error detected while processing function gitgutter#process_buffer[10]..gitgutter#diff#run_diff:
line 35:
"/var/folders/38/jh5yczrn3pn2g2g0hwf0yxc40000gv/T/vfjbkow/4.rb" E212: Can't open file for writing
Press ENTER or type command to continue

This pops up periodically, interfering with my editing until I either disable the plugin (I actually don't know how to do this) or close and reopen the Vim window.

AaronM04 commented 7 years ago

I think I found a temporary workaround, which is to mkdir /var/folders/38/jh5yczrn3pn2g2g0hwf0yxc40000gv/T/vfjbkow. I suppose the OS cleaned up that directory after a while, and gitgutter expected it to still exist.

airblade commented 7 years ago

That's right, the OS is cleaning the temp directories.

The easiest workaround is to close and reopen vim.

On 15 Dec 2016, at 17:57, Aaron Miller notifications@github.com wrote:

I think I found a temporary workaround, which is to mkdir /var/folders/38/jh5yczrn3pn2g2g0hwf0yxc40000gv/T/vfjbkow. I suppose the OS cleaned up that directory after a while, and gitgutter expected it to still exist.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

AaronM04 commented 7 years ago

In my opinion, it would improve usability of gitgutter if it created a new temp directory when this error occurs.

On December 15, 2016 12:58:36 PM PST, Andy Stewart notifications@github.com wrote:

That's right, the OS is cleaning the temp directories.

The easiest workaround is to close and reopen vim.

On 15 Dec 2016, at 17:57, Aaron Miller notifications@github.com wrote:

I think I found a temporary workaround, which is to mkdir /var/folders/38/jh5yczrn3pn2g2g0hwf0yxc40000gv/T/vfjbkow. I suppose the OS cleaned up that directory after a while, and gitgutter expected it to still exist.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/airblade/vim-gitgutter/issues/395#issuecomment-267442185

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

airblade commented 7 years ago

I agree but I feel it's better solved by Vim itself. GitGutter uses the temp file facility provided by Vim (tempname()) – I don't think it's within the scope of a plugin to handle problems with Vim's implementation.

BTW according to this SuperUser answer OS X deletes temp files and empty directories after 3 days of inactivity. On my OS X 10.11.6 the script is /etc/periodic/daily/110.clean-tmps.

AaronM04 commented 7 years ago

Ah, I didn't know about tempfile(). That does suggest that Vim should be fixed. Thanks!

On December 16, 2016 1:25:06 AM PST, Andy Stewart notifications@github.com wrote:

I agree but I feel it's better solved by Vim itself. GitGutter uses the temp file facility provided by Vim (tempname()) – I don't think it's within the scope of a plugin to handle problems with Vim's implementation.

BTW according to this SuperUser answer OS X deletes temp files and empty directories after 3 days of inactivity. On my OS X 10.11.6 the script is /etc/periodic/daily/110.clean-tmps.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/airblade/vim-gitgutter/issues/395#issuecomment-267552199

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

tnguyen14 commented 4 years ago

I am using a shared VM that I do not have sudo access to, and cannot change the temp cleaning behavior. I was hoping for a way around this instead of reopening vim.

AaronM04 commented 4 years ago

@tnguyen14 I ended up switching to vim-signify. It does not have this bug.

airblade commented 4 years ago

@AaronM04 vim-signify (here and here) and vim-gitgutter (here) both use tempname(). So they will behave the same way with respect to this issue.

AaronM04 commented 4 years ago

The disruptive error pop up is the issue I have only observed with vim-gitgutter. Presumably vim-signify handles missing temporary file failures differently.

airblade commented 4 years ago

Ah, looking at this with fresh eyes I realised the difference (explained in dab840b's commit message). This problem should be solved now.