Repository: lervag/vimtex

Issue #1256: Can't find temp file when call VimtexClean
Created: 2018-11-07T14:37:01Z
I know this is an old bug here, but I find something new that I can't understand here. I try to fix the error when I run :VimtexClean, which will popup an error message:
E484: Can't open file C:\Users\usrname\AppData\Local\Temp\VIoF1B7.tmp

The problem is that the VIoF1B7.tmp  can be found at the exactly location, and can be deleted without any permission.
While debugging, I finally find that this line causes the problem:
silent call system(self.prepared_cmd)
If I comment it completely, all thing gone (of course no clean at all). It seems strange to me that the self.prepared_cmd is
start /b cmd /s /c "cd /D "C:\Users\usrname\Desktop" & latexmk -c  -outdir=C:\Users\usrname\vimfiles\myvim\vimtemp "test.tex" >nul"
and the self discretionary is:
[['pid', 0], ['background', 1], ['continuous', 0], ['win32_restore_shell', 0], ['cmd', 'cd /D "C:\Users\usrname\Desktop" & latexmk -c  -outdir=C:\Users\usrname\vimfiles\myvim\vimtemp "test.tex"'], ['stop', function('5084')], ['_execute', function('5088')], ['workdir', ''], ['get_pid', function('5092')], ['silent', 1], ['_do_not_run', function('5086')], ['pprint_items', function('5085')], ['prepared_cmd', 'start /b cmd /s /c "cd /D "C:\Users\usrname\Desktop" & latexmk -c  -outdir=C:\Users\usrname\vimfiles\myvim\vimtemp "test.tex" >nul"'], ['_pre_run', function('5087')], ['output', 'null'], ['_post_run', function('5089')], ['run', function('5083')], ['_prepare', function('5090')], ['_restore', function('5091')]]
I learnt from this fix, that the VimtexClean call can be fixed by surround the l:cmd with double quote, while this fix violate the sumartpdf previewer call. So I think a if statement will work for this:
function! s:process._execute() abort dict " {{{1
  if self.silent
	echo items(self)
    if self.output == 'null'
		let self.prepared_cmd = '"' . self.prepared_cmd . '"'
	endif
    silent call system(self.prepared_cmd)
  elseif self.background
    silent execute '!' . self.prepared_cmd
    if !has('gui_running')
      redraw!
    endif
  else
    execute '!' . self.prepared_cmd
  endif
MY Question: I don't understand why there always a new temp file created whenever I call either VimtexCompile or VimtexClean, why we get such an error while the temp file exists?

Duplicate issue #2139: VimtexClean does not clean files (win10)
Created: 2021-08-19T16:28:53Z
Description
When I run :VimtexClean I can see cmd window running and after it is closed no files are deleted:

Steps to reproduce

<localleader>ll
wait till document is created
<localleader>ll
:VimtexClean

Expected behavior
All(?) or some generated files are deleted.
Actual behavior
Nothing is deleted.
Do you use a latexmkrc file?
No
VimtexInfo
System info
  OS: Microsoft Windows 10 Pro (10.0.19041 N/A Build 19041)
  Vim version: VIM 8.2 (1-3358)
  Has clientserver: true
  Servername: GVIM

VimTeX project: test
  base: test.tex
  root: C:\Users\maksim.kim\temp
  tex: C:\Users\maksim.kim\temp\test.tex
  out: C:\Users\maksim.kim\temp/test.pdf
  log: C:\Users\maksim.kim\temp/test.log
  aux: C:\Users\maksim.kim\temp/test.aux
  fls: C:\Users\maksim.kim\temp/test.fls
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -shell-escape
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -lualatex
  viewer: General
  qf: LaTeX logfile
    addqflist: 70
    fix_paths: 71
    set_errorformat: 69
  document class: article
  packages:
    atbegshi-ltx
    atveryend-ltx
    auxhook
    babel
    bigintcalc
    bitset
    calc
    catchfile
    color
    etexcmds
    etoolbox
    expl3
    fancyhdr
    fancyvrb
    float
    fontenc
    fontspec
    fontspec-luatex
    framed
    fvextra
    geometry
    gettitlestring
    hycolor
    hyperref
    ifluatex
    ifplatform
    iftex
    ifthen
    ifvtex
    infwarerr
    intcalc
    isodate
    keyval
    kvdefinekeys
    kvoptions
    kvsetkeys
    letltxmacro
    lineno
    ltxcmds
    mdframed
    minted
    nameref
    needspace
    pdfescape
    pdftexcmds
    refcount
    rerunfilecheck
    shellesc
    stringenc
    substr
    textcomp
    titlesec
    uniquecounter
    upquote
    url
    xcolor
    xparse
    xstring
    zref-abspage
    zref-base

Closing comment (2021-08-24T20:09:20Z): Reading #1256, I get the impression that the fix implemented there was not really very well justified. So I'll revert it for now. If @vanabel or anyone else then has an issue similar to #1256, then I could help investigate it and perhaps also ask you to assist.
So, with that: I'll push the change asap.