junegunn / junegunn/vim-plug

Error when trying to use PlugUpdate on Windows

Open
#919 1 comment 0 reactions 0 assignees View on GitHub
neovim
Dominant language
Vim Script
Stars
35.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/majutsushi/tagbar/issues/562).

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

```
|| Error detected while processing function
|| 7_update[1]
|| 7_update_impl[58]
|| 7_git_version_requirement[2]
|| E171: Missing :endif
|| Error detected while processing function
|| 7_update[1]
|| 7_update_impl[58]
|| 7_git_version_requirement[2]
|| 7_system[6]
|| 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](https://github.com/junegunn/vim-plug/blob/master/plug.vim#L414-L415):

```
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.