Vim complains about a temporary file when opening syntax highlighted files on Mac OS X

8

When I try to open a file (e.g. test/test_sequence.rb) using Vim or MacVim I get the following error:

"test/test_sequence.rb" 109L, 3697C
Vim(let):E484: Can't open file /var/folders/zO/zOCN9kiiGD4keWX3TWYEh++++TI/-Tmp-/vzTkbXD/0

This seems only restricted to files which have some kind of syntax highlighting. I can still edit the file but I have to use :w! to write the changes the first time. I'm using vim on Mac OS X. I tried a lot of googling for this error with no luck and this has become really frustrating. Could anyone offer a fix for this?

EDIT: I don't get this error when editing syntax highlighted LaTeX files but do with syntax highlighted Ruby files.

Michael Barton

Posted 2010-08-22T22:07:08.317

Reputation: 285

Answers

6

Turns out the problem was with the shell. Vim was trying to use /bin/screen as the shell

set shell /bin/sh

In my vimrc fixed the problem.

Michael Barton

Posted 2010-08-22T22:07:08.317

Reputation: 285

for me the syntax had to be set shell=/bin/sh – Ganesh Hegde – 2015-11-15T08:40:49.053

But the whole thing seems filetype=ruby-specific to me. – ThomasH – 2015-11-26T15:58:58.907

3Just hit this myself when I changed my login shell to fishshell. Thanks for the tip :) – Yeraze – 2013-11-08T16:13:17.570

Same here, after setting default shell to fish it happened to me :) – imslavko – 2013-11-23T20:54:03.820

3Well, it had to add: set shell=/bin/bash. – paldepind – 2014-02-19T08:19:01.493

1

I have found that if you su to a different user, processes trying to use temporary files may produce an error like /var/folders/zO/zOCN9kiiGD4keWX3TWYEh++++TI/-Tmp-/vzTkbXD/0: permission denied; the fix for this is to unset TMPDIR (which, I think, causes /tmp to be used instead), because the TMPDIR specified is specific to the old user and not writable by the current user.

You haven't said whether you're using su or any other user-switching, and the error message doesn't mention permission denied, but ...

Kevin Reid

Posted 2010-08-22T22:07:08.317

Reputation: 2 854

Thanks for the suggestion. I've tried changing the location of $TMPDIR to /tmp. I instead get an error pointing to /tmp/vzTkbXD/0 now though. – Michael Barton – 2010-09-02T18:05:52.130

1Try unset TMPDIR instead. And what is the error? If the message really doesn't show it, run sudo fs_usage MacVim (note that the named process must be already running) and note what the errno on its open() call is. – Kevin Reid – 2010-09-03T01:42:01.227

Thank you for your continued suggestions to try to resolve this for me, it's really appreciated. I've tried unsetting $TMPDIR but this doesn't resolve the error either.Unfortunately I'm not familiar with the fs_usage command and I couldn't produce an error number for the open process in the fs_usage output. I've pasted the complete output of fs_usage here if this is of any use - http://cl.ly/5c01de97b2276a73b569

– Michael Barton – 2010-09-12T19:51:15.863

0

Vim is trying to open a swap file, have you tried repairing permissions?

Josh K

Posted 2010-08-22T22:07:08.317

Reputation: 11 754

1Thanks for the suggestion. I've just run disk utility's repair permissions twice but I'm still seeing the same problem. – Michael Barton – 2010-08-23T21:31:10.267