vim script can't create /tmp file

2,883 views
Skip to first unread message

sinbad

unread,
Dec 3, 2012, 5:47:02 AM12/3/12
to vim...@googlegroups.com
one of the script in my vim environment is not able
to create a /tmp file, i keep getting the following
error. This script is invoked every time i write
the file contents.

Error detected while processing function GenerateTags:
line 1:
E484: Can't open file /tmp/vEmReRC/36


Interestingly i am not seeing this error for the first
few writes after i open the file. the workaround is to
open/close the file, and i won't see the error for first
few writes, after that again i see the same error. any
clues for why it is happening and how to fix it.

Marc Weber

unread,
Dec 3, 2012, 5:56:00 AM12/3/12
to vim_use
Excerpts from sinbad's message of Mon Dec 03 11:47:02 +0100 2012:
> one of the script in my vim environment is not able
> to create a /tmp file, i keep getting the following
> error. This script is invoked every time i write
> the file contents.
>
> Error detected while processing function GenerateTags:
> line 1:
> E484: Can't open file /tmp/vEmReRC/36

To my undestanding each vim instance creates /tmp/vEmReRC like
directory.

tempname() like functions return a new file within that directory.
Vim should cleanup on clean exit in that directory.

If vim can't write to that directory I have no idea what happened, but
you can explore yourself: Try accessing that file: can you touch, read
delete that /tmp/vEmReRC/36 file?

That might give you some insight about what might be going wrong.
Eg if you do rm -fr /tmp/* or such there will be an issue cause Vim won'
t recreate that directory.

Marc Weber

Christian Brabandt

unread,
Dec 3, 2012, 6:38:29 AM12/3/12
to vim...@googlegroups.com
Do you have some kind of clean up job running, that clears /tmp?

Then those errors happen. Vim creates that directory only the
first time, it needs a temp file. Subsequent calls expect the
temp directory to be existent.

regards,
Christian

sinbad

unread,
Dec 4, 2012, 12:13:14 AM12/4/12
to vim...@googlegroups.com, cbl...@256bit.org

Looks like the tmp file deletion is the problem.
when i started to see the errors i found that
tmp file is missing.

No i'm not running any cleanup job. how do i know
if someone else is deleting the file. is there a
way to protect the tmp file not to be deleted.
I do not suspect any of my other scripts are deleting
the file, as i did not install any new scripts, and i
was running with the same set of scripts for some
years without any problems

Christian Brabandt

unread,
Dec 4, 2012, 3:37:13 AM12/4/12
to sinbad, vim...@googlegroups.com
On Tue, December 4, 2012 06:13, sinbad wrote:
> Looks like the tmp file deletion is the problem.
> when i started to see the errors i found that
> tmp file is missing.
>
> No i'm not running any cleanup job. how do i know
> if someone else is deleting the file. is there a
> way to protect the tmp file not to be deleted.
> I do not suspect any of my other scripts are deleting
> the file, as i did not install any new scripts, and i
> was running with the same set of scripts for some
> years without any problems

Check your cron jobs and check the installed packages.
A package name such as tmpreaper is suspicious.

An unconventional approach would be to create a file /tmp/dummy
chattr +i it and watch the logs, if some program is complaining.

regards,
Christian

sinbad

unread,
Dec 4, 2012, 8:16:46 AM12/4/12
to vim...@googlegroups.com, sinbad, cbl...@256bit.org

actually i don't have the root permission.
i'm getting the following error,

chattr: Operation not permitted while setting flags on vXrMR9M

is there a way to check if any of my vim script is deleting the
file.

thanks
sinbad

David Fishburn

unread,
Dec 4, 2012, 8:32:34 AM12/4/12
to vim_use
...
Looks like the tmp file deletion is the problem.
when i started to see the errors i found that
tmp file is missing.

No i'm not running any cleanup job. how do i know
if someone else is deleting the file. is there a
way to protect the tmp file not to be deleted.
I do not suspect any of my other scripts are deleting
the file, as i did not install any new scripts, and i
was running with the same set of scripts for some
years without any problems

Is this a Vim you compiled yourself?

David
 

sinbad

unread,
Dec 4, 2012, 8:54:08 AM12/4/12
to vim...@googlegroups.com

yes. i compiled it myself.

sinbad

unread,
Dec 5, 2012, 3:37:49 AM12/5/12
to vim...@googlegroups.com

any other pointers on how to get rid of this error.
it's became very annoying.

David Fishburn

unread,
Dec 5, 2012, 8:09:41 AM12/5/12
to vim_use
...
> > Is this a Vim you compiled yourself?
> >
> >
> > David
>
> yes. i compiled it myself.

any other pointers on how to get rid of this error.
it's became very annoying.

The reason I asked is I ran into a similar issue (on Windows, https://groups.google.com/forum/?fromgroups=#!topic/vim_use/JSXaM9YjWKo) after compiling my own version of Vim (which I do routinely).

After updating again and recompiling, the problem went away.

Perhaps you have run into a similar issue and a recompile might get you going?

HTH,
David
 

Christian Brabandt

unread,
Dec 5, 2012, 11:55:58 AM12/5/12
to vim...@googlegroups.com
On Wed, December 5, 2012 09:37, sinbad wrote:
> any other pointers on how to get rid of this error.
> it's became very annoying.

Have you checked all your cronjobs and scripts, that you run?
Can you eliminate, that root doesn't run some jobs, that clean /tmp?

I once made a patch, that changed Vims behaviour to check everytime,
whether the temp directory is still valid and if not re-create it,
but Bram didn't want to include it.

Since this happens usually only very rarely, I have this command
in my .vimrc:
" In case /tmp get's clean out, make a new tmp directory for vim
:command! Mktmpdir call mkdir(fnamemodify(tempname(),":p:h"),"",0700)

regards,
Christian

Gary Johnson

unread,
Dec 5, 2012, 12:21:05 PM12/5/12
to vim...@googlegroups.com
On 2012-12-05, Christian Brabandt wrote:
> On Wed, December 5, 2012 09:37, sinbad wrote:
> > any other pointers on how to get rid of this error.
> > it's became very annoying.
>
> Have you checked all your cronjobs and scripts, that you run?
> Can you eliminate, that root doesn't run some jobs, that clean /tmp?

You may have to do some digging to find root's cron jobs. For
example, on my Ubuntu 10.04 system, "sudo cron -l -u root" says that
root has no cron jobs, but it does run /etc/crontab and the scripts
in /etc/cron.d. It doesn't clean /tmp, though.

Gary

sinbad

unread,
Dec 11, 2012, 1:15:16 AM12/11/12
to vim...@googlegroups.com, gary...@spocom.com

I am running as non-root and i don't have sudo
permission, i was not able to check the root's
cron jobs, i checked mine there are no cron
jobs running. am i screwed ?

Christian Brabandt

unread,
Dec 11, 2012, 2:00:50 AM12/11/12
to vim...@googlegroups.com
On Tue, December 11, 2012 07:15, sinbad wrote:
> I am running as non-root and i don't have sudo
> permission, i was not able to check the root's
> cron jobs, i checked mine there are no cron
> jobs running. am i screwed ?

It's annoying but you are not screwed. Simply recreate that
directory and you should be fine. See the command, I posted
earlier.

regards,
Christian

Gary Johnson

unread,
Dec 11, 2012, 2:21:56 AM12/11/12
to vim...@googlegroups.com
On 2012-12-10, sinbad wrote:
> On Wednesday, December 5, 2012 10:51:05 PM UTC+5:30, Gary Johnson wrote:
> > On 2012-12-05, Christian Brabandt wrote:

> > > Have you checked all your cronjobs and scripts, that you run?
> > > Can you eliminate, that root doesn't run some jobs, that clean /tmp?
> >
> > You may have to do some digging to find root's cron jobs. For
> > example, on my Ubuntu 10.04 system, "sudo cron -l -u root" says that
> > root has no cron jobs, but it does run /etc/crontab and the scripts
> > in /etc/cron.d. It doesn't clean /tmp, though.

> I am running as non-root and i don't have sudo
> permission, i was not able to check the root's
> cron jobs, i checked mine there are no cron
> jobs running. am i screwed ?

I don't think it's hopeless, but may be difficult to find the cause.

You wrote that you don't have root or sudo permission. That
suggests that you are using a computer administered by someone else.
Can you just ask that person or someone in that group if they know
of any /tmp-cleaning program that might be running?

On my Ubuntu 10.04 and Fedora 14 systems, all the /etc/cron* files
have 755 permissions, so you could poke around there and see if you
can find some /tmp cleaner.

It _might_ help to know the timing of these deletions. Do they
happen after Vim has been running for a certain amount of time? Do
they happen at certain times of day, or at a certain number of
minutes past the hour? That might give you a clue to the cause. If
you could predict the times at which it occurs, you could possibly
run "ps -ef" in a loop at that time and look for suspicious
processes.

HTH,
Gary

sinbad

unread,
Dec 11, 2012, 4:17:29 AM12/11/12
to vim...@googlegroups.com, gary...@spocom.com

there are two possibilities here, first one of vim
script is deleting the tmpfile, the other is some cron
job might be deleting it. in the first case can i put a
watch on the tmpfile created from with in vim. In the
latter case, can i force vim to create the tmp directory
in my homedir rather than in /tmp so that the cron job
won't have access to it. please suggest ways to achieve
above.

Gary Johnson

unread,
Dec 11, 2012, 11:06:53 AM12/11/12
to vim...@googlegroups.com
On 2012-12-11, sinbad wrote:

> there are two possibilities here, first one of vim
> script is deleting the tmpfile, the other is some cron
> job might be deleting it. in the first case can i put a
> watch on the tmpfile created from with in vim. In the
> latter case, can i force vim to create the tmp directory
> in my homedir rather than in /tmp so that the cron job
> won't have access to it. please suggest ways to achieve
> above.

Somebody suggested earlier a way to put a watch on that tmpfile, but
you apparently don't have permission to do that.

As for putting your tmp directory someplace else,

:help tempfile

says that on Unix, Vim uses the first of this list of directories:
$TMPDIR, /tmp, current-dir, $HOME. Therefore, you could set TMPDIR
in your environment before starting Vim, either by setting it in
your shell's .rc file (e.g., ~/.bashrc) or by setting it as you
start Vim, e.g.,

TMPFILE=~/tmp vim

You could put that in a wrapper script or in an alias:

alias vim='TMPFILE=~/tmp vim'

Regards,
Gary

Gary Johnson

unread,
Dec 11, 2012, 11:40:02 AM12/11/12
to vim...@googlegroups.com
An even easier way is to put a line like this towards the top of
your ~/.vimrc:

let $TMPDIR = $HOME."/tmp"

Regards,
Gary

sinbad

unread,
Dec 14, 2012, 1:35:49 AM12/14/12
to vim...@googlegroups.com, gary...@spocom.com

Gary, Christian, thanks for the help.
setting $TMPDIR to my homedir solved
the problem, so it's really one of the
root's cron jobs screwing with my /tmp
files.

Reply all
Reply to author
Forward
0 new messages