tagbar icon indicating copy to clipboard operation
tagbar copied to clipboard

Error detected while processing function do_delayed_update

Open jdhao opened this issue 4 years ago • 5 comments

I am using tagbar on Windows and met this error:

|| <SNR>194_do_delayed_update[11] || <SNR>194_AutoUpdate[56] || <SNR>194_ProcessFile[42] || E482: Can't open file C:\Users\ADMINI~1\AppData\Local\Temp\nvimsw7TqN\11.md for writing: no such file or directory

I checked the source code of the function ProcessFile and the relevant line is:

let tempfile = tempname()
let ext = fnamemodify(fileinfo.fpath, ':e')
if ext !=# ''
    let tempfile .= '.' . ext
endif

call tagbar#debug#log('Caching file into: ' . tempfile)
let templines = getbufline(fileinfo.bufnr, 1, '$')
let res = writefile(templines, tempfile)

This error is caused by the missing tempfile. i.e., the tempfile does not exist. So it is better to make sure this file actually exists before writing to it.

The issue is related to https://github.com/neovim/neovim/issues/11250.

It seems that writefile() only works if the folder containing the file exists. It is necessary to create the intermediate tmp folder under C:\Users\ADMINI~1\AppData\Local\Temp and then write the file. Something like the following:

let tempfile = tempname()

if !exists(tempfile)
    call mkdir(fnamemodify(tempfile, ":h"), "p")
endif
....

let res = writefile(some_list, tempfile)

jdhao avatar Nov 07 '19 03:11 jdhao

Thanks for taking the time to figure this out an report on it @jdhao. Unfortunately I do not have a Windows system to even test this on. Would you be willing to actually fix this and submit is as a PR? I'd rather you do that then I copy the code from here because you can experimentally test that it actually works as expected. I'll be happy to review and merge any PR that fixes the issue for people, it's just not something I can very easily work on myself.

alerque avatar Nov 07 '19 04:11 alerque

@alerque , I am not familiar with the code of tagbar. I am not sure if the changes will cause side effects which I am not aware of.

jdhao avatar Nov 11 '19 06:11 jdhao

Same issue on centos7 with vim8.2 FileError detected while processing function tagbar#currenttag[16]..<SNR>104_Init[4]..<SNR>104_CheckForExCtags[55]..<SNR>104_ExecuteCtags[34]..<SNR>104_run_system:

TanishBansal avatar Oct 24 '20 09:10 TanishBansal

@TanishBansal The error you are seeing looks to be a separate issue from the one reported in this thread. Can you please open a new issue for your error? Also please include the output of vim --version and ctags --version. If possible, can you also include a debug log file for your issue? You can do this during vim init by adding the following to your .vimrc

let g:tagbar_logfile = ~/tagbar_debug.log
execute 'TagbarDebug ' . g:tagbar_logfile

Or you can specify some other filename if you prefer. But if we could see the version info of the programs, and the debug output it will help us diagnose the problem. Though again this should be tracked under a separate issue as this one is specific to windows temp file creation.

raven42 avatar Oct 24 '20 12:10 raven42

@jdhao Can you try the tempname() workaround listed in #723 to see if this helps your issue too?

raven42 avatar Jan 11 '21 13:01 raven42