vim-plug icon indicating copy to clipboard operation
vim-plug copied to clipboard

Error when trying to use PlugUpdate on Windows

Open jdhao opened this issue 4 years ago • 1 comments

I think this is an ongoing issue with tempfiles on Windows, the related issue has been reported on https://github.com/junegunn/vim-plug/issues/900 and https://github.com/junegunn/vim-plug/issues/852. A similar issue has also been reported here.

Unfortunately, there are still bugs related to this issue. The error message is as follows:

|| Error detected while processing function
|| <SNR>7_update[1]
|| <SNR>7_update_impl[58]
|| <SNR>7_git_version_requirement[2]
|| E171: Missing :endif
|| Error detected while processing function
|| <SNR>7_update[1]
|| <SNR>7_update_impl[58]
|| <SNR>7_git_version_requirement[2]
|| <SNR>7_system[6]
|| <SNR>7_batchfile[2]
|| E482: Can't open file C:\Users\ADMINI~1\AppData\Local\Temp\nvim6Xrddz\2.bat for writing: no such file or directory

I tracked the stack trace of the error and pinpoint the issue to these two lines:

let batchfile = s:plug_tempname().'.bat'
call writefile(s:wrap_cmds(a:cmd), batchfile)

The directory containing the file returned by s:plug_tempname() may not exist, and in that case, the call to function writefile() will fail.

Maybe it is better to add some checking to see whether the directory containing the file exists before writing the file and create that directory if necessary, something like the following:

batchfile_parent = fnamemodify(batchfile, ":h")
if !isdirectory(batchfile_parent)
    call mkdir(batchfile_parent, "p")
endif

Neovim version info:

NVIM v0.5.0-172-g1ff5b60cb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe /DWIN32 /D_WINDOWS /W3 /MD /Zi /O2 /Ob1 /DNDEBUG -DMIN_LOG_LEVEL=3 /W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -D_WIN32_WINNT=0x0600 -DINCLUDE_GENERATED_DECLARATIONS -DUTF8PROC_STATIC -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -IC:/projects/neovim/build/config -IC:/projects/neovim/src -IC:/projects/nvim-deps/usr/include -IC:/projects/neovim/build/src/nvim/auto -IC:/projects/neovim/build/include
Compiled by appveyor@APPVYR-WIN

Features: -acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files/nvim/share/nvim"

Run :checkhealth for more info
  • Type:
    • [x] Bug
    • [ ] Enhancement
    • [ ] Feature Request
    • [ ] Question
  • OS:
    • [ ] All/Other
    • [ ] Linux
    • [ ] OS X
    • [x] Windows
  • Vim:
    • [ ] Terminal Vim
    • [ ] GVim
    • [x] Neovim

jdhao avatar Dec 13 '19 03:12 jdhao

Instead of recreating the directory that Neovim should exclusively own, create a temporary directory exclusive to vim-plug.

janlazo avatar Dec 13 '19 04:12 janlazo