0

On gvim for Windows I wanted to change the termial from cmd to wsl, so I added this to my gvimrc. which I got from an answer on another StackExchange site:

" Use WSL as terminal on Windows
if has("win32")
    set shell=C:\Windows\Sysnative\wsl.exe
    set shellpipe=|
    set shellredir=>
    set shellcmdflag=
endif

This works, but I get this error in gvim:

Error detected while processing BufEnter Autocommands for "*":
E484: Cannot open file C:\Users\jason\AppData\Local\Temp\VZ7302.tmp

The file name is always different and never exists at the stated location, but they do exist in C:\Users\jason\vimfiles\ like this:

jason@helios:~/winhome/vimfiles$ ls -l
.rw-r--r-- 1    0 jason jason 18 Mar 16:47 C:UsersjasonAppDataLocalTempV3F6F2F.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 16:50 C:UsersjasonAppDataLocalTempV3F150C.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 16:45 C:UsersjasonAppDataLocalTempV3F762C.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 16:44 C:UsersjasonAppDataLocalTempV3FA146.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 16:44 C:UsersjasonAppDataLocalTempV3FC5E6.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 16:50 C:UsersjasonAppDataLocalTempV3FFA40.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 19:53 C:UsersjasonAppDataLocalTempVZ7B35F.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 19:51 C:UsersjasonAppDataLocalTempVZ7D4DA.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 19:54 C:UsersjasonAppDataLocalTempVZ73D2.tmp
.rw-r--r-- 1    0 jason jason 18 Mar 19:55 C:UsersjasonAppDataLocalTempVZ74A0E.tmp

It looks like these files are being created without the backslashes, so they appear in the runtime directory instead of where they should be. How do I stop this from happening?

7
  • Try :set shellslash Mar 19 at 16:24
  • @ChristianBrabandt That seemed promising, but it didn't change anything regarding this error. Is there anything else I could try?
    – paradroid
    Mar 21 at 5:48
  • did this change anything on those temp files? Mar 21 at 10:17
  • @ChristianBrabandt After deleting the existing temp files in that location, I have realised that no new ones are being created there anymore, but the error still comes up and is the same (apart from the random file names). The files do not seem to be in the correct location either.
    – paradroid
    Mar 21 at 14:29
  • try :set verbose=5 or something. Perhaps this gives a clue what is wrong Mar 22 at 8:41

1 Answer 1

0

The first part of the solution came from the comments above, which was to add set shellslash.

The second part of the problem turned out to be unique to me, but how I found the solution could be relevant for others:

With set verbose=5 it led to an error mentioning tmux:

Calling shell to execute: "(tmux...n\AppData\Local\Temp\VZ7AADD.tmp"

Although I use tmux, I couldn't see how it had anything to do with me using gVim on Windows, so I grepped for any mentions of tmux in the vimfiles, which I share with my Linux configuration.

It turned out that an autocmd that I used for tmux window renaming was somehow causing this, so wrapping it with a conditional statement solved the problem.

if exists('$TMUX')
  ...
endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.