Error with :.! commands

59 views
Skip to first unread message

Chandra

unread,
Jun 22, 2011, 3:41:09 PM6/22/11
to vim_use
Hello,
I see the following error when I try to in-line execute a shell
command something like

:.!grep foo bar


"/tmp/v454263/17" E212: Can't open file for writing
E482: Can't create file /tmp/v454263/17


It usually happens if the vim session has been on for a long time
without ever closing and reopening vim.
A fresh vim session does not give this error. Any idea what happens
here?

Thanks,
Chandra

Ben Fritz

unread,
Jun 22, 2011, 4:04:17 PM6/22/11
to vim_use
Possibly the temp directory got deleted out from under you. I'm not
sure of a good way around this.

Gary Johnson

unread,
Jun 22, 2011, 5:03:51 PM6/22/11
to vim_use
On 2011-06-22, Ben Fritz wrote:

When I've run into this I've just recreated the directory, e.g.,

:!mkdir /tmp/v454263

Regards,
Gary

Christian Brabandt

unread,
Jun 22, 2011, 5:14:17 PM6/22/11
to vim_use
Hi Gary!

Yeah, that is the only way around it. Some time ago, I made a patch
(http://groups.google.com/group/vim_dev/browse_frm/thread/728829f95c9ee28a/5d65508d4e21316a?lnk=gst&q=patch+temp+dir#5d65508d4e21316a)
that would make Vim check first, whether the directory still exists and
would create a new one, if it doesn't, but Bram didn't want to include
it.

Hm, I wonder whether one could catch E482 or E483 globally and try to
recreate the missing directory.

regards,
Christian

Gary Johnson

unread,
Jun 22, 2011, 5:40:40 PM6/22/11
to vim_use

That would be really useful. It's a shame Bram rejected it.

> Hm, I wonder whether one could catch E482 or E483 globally and try to
> recreate the missing directory.

Nice idea, but I didn't see any autocommand events that were
triggered by errors or anything applicable under ":help
ignore-errors".

Regards,
Gary

Chandra

unread,
Jun 23, 2011, 2:43:54 PM6/23/11
to vim_use
Thanks for the mkdir suggestion. Next time I face it, it will come in
handy.

-Chandra

On Jun 22, 2:40 pm, Gary Johnson <garyj...@spocom.com> wrote:
> On 2011-06-22, Christian Brabandt wrote:
>
>
>
>
>
>
>
>
>
> > Hi Gary!
>
> > On Mi, 22 Jun 2011, Gary Johnson wrote:
>
> > > On 2011-06-22, Ben Fritz wrote:
> > > > On Jun 22, 2:41 pm, Chandra wrote:
> > > > > Hello,
> > > > > I see the following error when I try to in-line execute a shell
> > > > > command something like
>
> > > > > :.!grep foo bar
>
> > > > > "/tmp/v454263/17" E212: Can't open file for writing
> > > > > E482: Can't create file /tmp/v454263/17
>
> > > > > It usually happens if the vim session has been on for a long time
> > > > > without ever closing and reopening vim.
> > > > > A fresh vim session does not give this error. Any idea what happens
> > > > > here?
>
> > > > Possibly the temp directory got deleted out from under you. I'm not
> > > > sure of a good way around this.
>
> > > When I've run into this I've just recreated the directory, e.g.,
>
> > >    :!mkdir /tmp/v454263
>
> > Yeah, that is the only way around it. Some time ago, I made a patch
> > (http://groups.google.com/group/vim_dev/browse_frm/thread/728829f95c9e...)

Ben Schmidt

unread,
Jun 24, 2011, 12:39:18 AM6/24/11
to vim...@googlegroups.com, Chandra
> Thanks for the mkdir suggestion. Next time I face it, it will come in
> handy.

I made myself a command to do it some time ago, which you may find
useful:

command! Mktmpdir call mkdir(fnamemodify(tempname(),":p:h"),"",0700)

Ben.

Ben Schmidt

unread,
Jun 27, 2011, 9:29:03 PM6/27/11
to Chandrasekaran Venkatraman, vim use
>> command! Mktmpdir call mkdir(fnamemodify(tempname(),"__:p:h"),"",0700)
>
> This is completely obscure to me. Where do I put this line?

You put the line in your ~/.vimrc ($HOME/_vimrc on Windows, I think) and
it defines a custom command, so when you want to use it, you just issue
:Mktmpdir from the commandline.

Hope that helps!

Ben.

Reply all
Reply to author
Forward
0 new messages