Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim error: can't open file /tmp/.* when run some commands need temporary files

Tags:

vim

Gentoo, vim version 7.3.762

Problem:
ONLY happened when the vim instance has been ran for a long time (like 2 hours). Then I ran some commands which require temporary files like :Gstatus in plugin fugitive, I will get an error:

can't open file /tmp/RANDOM_NAME

I can't figure out what the reason caused this. Is it has anything to do with the auto-clean strategy of the operating system?
Because I encountered this problem not only when running the fugitive commands, but also the function below:

" Use ranger as vim's file chooser
fun! RangerChooser()
    silent !ranger --choosefile=/tmp/chosenfile $([ -z '%' ] && echo -n . || dirname %)
    if filereadable('/tmp/chosenfile')
        exec 'edit ' . system('cat /tmp/chosenfile')
        call system('rm /tmp/chosenfile')
    endif
    redraw!
endfun
like image 487
Yang Liu Avatar asked Oct 31 '13 02:10

Yang Liu


1 Answers

I ran into this problem because I had recently changed my shell from fish to bash. Changing my shell in my vimrc fixed the problem:

set shell=/bin/bash

like image 67
mcartmell Avatar answered Oct 26 '22 07:10

mcartmell