lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.42k stars 389 forks source link

Error while running :VimtexCompile #1195

Closed hicsuntdragons closed 6 years ago

hicsuntdragons commented 6 years ago

The following happens with every '.tex' file i try to run. I open vim, run the compiler function, and it gives the folowing error:

Error detected while processing function vimtex#compiler#compile[5]..40[24]..42[39]..232[5]..237:
line 2:
E484: Can't open file $appdata$\Local\Temp\VIoFE12.tmp

The temporary file name aways changes.

When i run the compiler for the first time, it compiles, despite the error. if I try to stop the interpreter (:VimtexStopAll) and run again, it doesn't work anymore. If i try to open, compile, then make a change and :w it, vimtex also works.

I tested latexmk im cmd and it works fine:

cd $path_to_tex$
latexmk -pdf main.tex

Honest warning: i installed miktex couple months ago, and it stopped working completely. then, this error started. then, i clean re-installed miktex with latexmk.pl and tested on cmd, working fine, but the error didn't disappear. I tried re-installing vimtex to no resolution.

Some of my vimrc file:

if has('win32')
        let $PATH .= ';' . 'C:\Program Files (x86)\SumatraPDF'
    let $PATH .= ';' . 'C:\Strawberry\perl\bin'
    let $PYTHONHOME =  'C:\Users\julia\AppData\Local\Programs\Python\Python35'
endif

call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-sensible'
Plug 'lervag/vimtex'
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'
Plug 'neomake/neomake'
Plug 'Valloric/YouCompleteMe'
"Plug 'SirVer/ultisnips' "unistalled for debuging of issue
"Plug 'ludovicchabant/vim-gutentags' "unistalled for debug of issue
call plug#end()

let g:latex_viewer='SumatraPDF'
let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
    \ = '-reuse-instance -forward-search @tex @line @pdf'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'

 if !exists('g:ycm_semantic_triggers')
    let g:ycm_semantic_triggers = {}
  endif
  let g:ycm_semantic_triggers.tex = g:vimtex#re#youcompleteme

nmap <F2> :VimtexCompile
nmap <F3> :VimtexView<CR>

And a minimal.tex:

\documentclass[oneside,a4paper,12pt,fleqn,english,french,spanish,brazil]{abntex2}
\include{meta}

\begin{document}

\frontmatter
\pagenumbering{arabic}
\include{pre}   % Capa, prefácio e afins

\textual

\mainmatter
\pagenumbering{arabic}
\include{cap_1}
\include{cap_2}
\include{cap_3}
\include{cap_4}
\emph{compileTest}
% Arquivo .bib
\bibliography{referencias}

% Fim do texto
\end{document}
lervag commented 6 years ago

Ok, first, some basics: Can you please provide which OS you are on (obviously Windows, but which version)? And which version of Vim?

I honestly don't know much about Windows systems, but I searched around and I found some things that might help:

  1. Someone had a similar issue, my link should take you to a possible solution:

    set shell=cmd
    set shellcmdflag=/c

    Please read the thread and see if this might be related to your issue. In particular, it seems like doing :echo system('dir') should be enough to reproduce your issue. It also seems to be due to your shell settings or similar.

  2. Another thing that might be related is this vim.wikia.com post. It says that the problem might be due to read/write permissions, and that you might need to change the $TMP and $TEMP variales.

PS! I took the liberty of updating your post with proper formatting.

hicsuntdragons commented 6 years ago

Ok, first, some basics: Can you please provide which OS you are on (obviously Windows, but which version)? And which version of Vim?

Windows and Vim Version: Windows 10 Home x64, with vim 7.4 x64.

  1. Someone had a similar issue, my link should take you to a possible solution

I just tried and tested that. Unfortunately didn't work. Also, I see to have no problem in using :echo system('dir').

  1. Another thing that might be related is this vim.wikia.com post.

I created the new temp folder, and now the error has transfered to it xD

PS! I took the liberty of updating your post with proper formatting.

Many thanks! I'm new in github :)

I ran some tests tweaking my _vimrc configs on and off and nothing happened, but now I am noticing that other plugins are presenting unusual behavior. I'm starting to suspect that something is broken with my vim-plug installation. I will investigate this.

lervag commented 6 years ago

Thanks for new input!

I think you should try to strip down to a real minimal example. I.e., create a minimal vimrc file such as this:

set nocompatible
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable

let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
  \ = '-reuse-instance -forward-search @tex @line @pdf'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'

As well as a minimal tex file, such as this:

\documentclass{minimal}
\begin{document}

Hello World!

\end{document}

Now, from a cmd prompt, you can go to the directory where you've put the files, then do gvim -u minivimrc minimal.tex. Does the problem still persist?

hicsuntdragons commented 6 years ago

I made several tests using minimal vimrc and minimal .tex, and the problem persisted.

minimal _vimrc:

set nocompatible
let &rtp = '~/.vim/plugged/vimtex,' . &rtp
let &rtp .= ',~/.vim/plugged/vimtex/after'
filetype plugin indent on
syntax enable

"added necessary folders to path.

let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
  \ = '-reuse-instance -forward-search @tex @line @pdf'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'

Minimal .tex:

\documentclass{minimal}
\begin{document}
test compiler 2
\end{document}
lervag commented 6 years ago

I updated your formatting again. Please take the opportunity to learn the formatting syntax yourself, it is pretty straightforward, and properly formatted posts are much easier to read.

So, what does "added necessary folders to path." mean? How is this related to your_vimrc` file?

Further, I assume the problem persist if you remove the vimtex options as well, they should not be relevant here. Can you verify that? I would also suspect that you can remove the second let &rtp .= ... line.

All in all, it seems you can reproduce the problem with a minimal vimrc file, which is good. And if I'm right, you should be able to reproduce with the following even more minimal vimrc file:

set nocompatible
let &rtp = '~/.vim/plugged/vimtex,' . &rtp
filetype plugin indent on
syntax enable

Please confirm.

Next step, after doing gvim -u minivimrc minimal.tex from a terminal, please provide the output of :scriptnames, which should show the various scripts that have been loaded. This should be a relatively short list.

hicsuntdragons commented 6 years ago

Folowing Your Recomendations

So, what does "added necessary folders to path." mean? How is this related to your_vimrc` file?

Well, for windows cmd to recognize certain executables without needing to cd to their folder, you add the folder to the $PATH enviroment variable. I was referring to it. That could lead to vim not finding the perl interpreter, or python, or sumatrapdf. I used to chain the folders used only for vim inside the _vimrc, but for the minvimrc, all was moved to the enviroment variable.

Obs.: Thinking about "minimal setup", I removed pyhton35 folder and sumatra folder from $PATH.

Further, I assume the problem persist if you remove the vimtex options as well

Yes, it persists. but initially gives the "selected viewer is not executable!" warning.

you should be able to reproduce with the following even more minimal vimrc file:

Right again! :)

please provide the output of :scriptnames

Well, its not that short...

1: ~\documentosTeX\minimal\minvimrc 2: C:\Program Files\Vim\vim74\filetype.vim 3: C:\Program Files\Vim\vim74\menu.vim 4: C:\Program Files\Vim\vim74\lang\menu_pt_br.latin1.vim 5: C:\Program Files\Vim\vim74\lang\menu_pt_br.vim 6: C:\Program Files\Vim\vim74\lang\menu_pt_br.utf-8.vim 7: C:\Program Files\Vim\vim74\lang\menu_pt_pt.latin1.vim 8: C:\Program Files\Vim\vim74\lang\menu_pt_pt.vim 9: C:\Program Files\Vim\vim74\lang\menu_pt_pt.utf-8.vim 10: C:\Program Files\Vim\vim74\autoload\paste.vim 11: C:\Program Files\Vim\vim74\ftplugin.vim 12: C:\Program Files\Vim\vim74\indent.vim 13: C:\Program Files\Vim\vim74\syntax\syntax.vim 14: C:\Program Files\Vim\vim74\syntax\synload.vim 15: C:\Program Files\Vim\vim74\syntax\syncolor.vim 16: C:\Program Files\Vim\vim74\plugin\getscriptPlugin.vim 17: C:\Program Files\Vim\vim74\plugin\gzip.vim 18: C:\Program Files\Vim\vim74\plugin\logiPat.vim 19: C:\Program Files\Vim\vim74\plugin\manpager.vim 20: C:\Program Files\Vim\vim74\plugin\matchparen.vim 21: C:\Program Files\Vim\vim74\plugin\netrwPlugin.vim 22: C:\Program Files\Vim\vim74\plugin\rrhelper.vim 23: C:\Program Files\Vim\vim74\plugin\spellfile.vim 24: C:\Program Files\Vim\vim74\plugin\tarPlugin.vim 25: C:\Program Files\Vim\vim74\plugin\tohtml.vim 26: C:\Program Files\Vim\vim74\plugin\vimballPlugin.vim 27: C:\Program Files\Vim\vim74\plugin\zipPlugin.vim 28: ~.vim\plugged\vimtex\ftplugin\tex.vim 29: ~.vim\plugged\vimtex\autoload\vimtex.vim 30: ~.vim\plugged\vimtex\autoload\vimtex\util.vim 31: ~.vim\plugged\vimtex\autoload\vimtex\state.vim 32: ~.vim\plugged\vimtex\autoload\vimtex\parser.vim 33: ~.vim\plugged\vimtex\autoload\vimtex\parser\general.vim 34: ~.vim\plugged\vimtex\autoload\vimtex\re.vim 35: ~.vim\plugged\vimtex\autoload\vimtex\paths.vim 36: ~.vim\plugged\vimtex\autoload\vimtex\view.vim 37: ~.vim\plugged\vimtex\autoload\vimtex\view\general.vim 38: ~.vim\plugged\vimtex\autoload\vimtex\log.vim 39: ~.vim\plugged\vimtex\autoload\vimtex\debug.vim 40: ~.vim\plugged\vimtex\autoload\vimtex\echo.vim 41: ~.vim\plugged\vimtex\autoload\vimtex\compiler.vim 42: ~.vim\plugged\vimtex\autoload\vimtex\compiler\latexmk.vim 43: ~.vim\plugged\vimtex\autoload\vimtex\qf.vim 44: ~.vim\plugged\vimtex\autoload\vimtex\qf\latexlog.vim 45: ~.vim\plugged\vimtex\autoload\vimtex\toc.vim 46: ~.vim\plugged\vimtex\autoload\vimtex\index.vim 47: ~.vim\plugged\vimtex\autoload\vimtex\labels.vim 48: ~.vim\plugged\vimtex\autoload\vimtex\fold.vim 49: ~.vim\plugged\vimtex\autoload\vimtex\fold\envs.vim 50: ~.vim\plugged\vimtex\autoload\vimtex\fold\cmd_single_opt.vim 51: ~.vim\plugged\vimtex\autoload\vimtex\fold\markers.vim 52: ~.vim\plugged\vimtex\autoload\vimtex\fold\preamble.vim 53: ~.vim\plugged\vimtex\autoload\vimtex\fold\sections.vim 54: ~.vim\plugged\vimtex\autoload\vimtex\fold\cmd_addplot.vim 55: ~.vim\plugged\vimtex\autoload\vimtex\fold\env_options.vim 56: ~.vim\plugged\vimtex\autoload\vimtex\fold\cmd_multi.vim 57: ~.vim\plugged\vimtex\autoload\vimtex\fold\cmd_single.vim 58: ~.vim\plugged\vimtex\autoload\vimtex\cmd.vim 59: ~.vim\plugged\vimtex\autoload\vimtex\complete.vim 60: ~.vim\plugged\vimtex\autoload\vimtex\delim.vim 61: ~.vim\plugged\vimtex\autoload\vimtex\doc.vim 62: ~.vim\plugged\vimtex\autoload\vimtex\env.vim 63: ~.vim\plugged\vimtex\autoload\vimtex\format.vim 64: ~.vim\plugged\vimtex\autoload\vimtex\imaps.vim 65: ~.vim\plugged\vimtex\autoload\vimtex\include.vim 66: ~.vim\plugged\vimtex\autoload\vimtex\info.vim 67: ~.vim\plugged\vimtex\autoload\vimtex\kpsewhich.vim 68: ~.vim\plugged\vimtex\autoload\vimtex\matchparen.vim 69: ~.vim\plugged\vimtex\autoload\vimtex\pos.vim 70: ~.vim\plugged\vimtex\autoload\vimtex\misc.vim 71: ~.vim\plugged\vimtex\autoload\vimtex\motion.vim 72: ~.vim\plugged\vimtex\autoload\vimtex\process.vim 73: ~.vim\plugged\vimtex\autoload\vimtex\profile.vim 74: ~.vim\plugged\vimtex\autoload\vimtex\scratch.vim 75: ~.vim\plugged\vimtex\autoload\vimtex\text_obj.vim 76: C:\Program Files\Vim\vim74\ftplugin\tex.vim 77: ~.vim\plugged\vimtex\indent\tex.vim 78: C:\Program Files\Vim\vim74\indent\tex.vim 79: C:\Program Files\Vim\vim74\syntax\tex.vim 80: ~.vim\plugged\vimtex\autoload\vimtex\qf\bibtex.vim

Extra Silly Testing

I got angry and just clean reinstalled vim due to other weird behavior. It was as painful as it sounds. In the end, I reinstalled vim-plug and vimtex, got hopeful, same problem, got frustrated again.

Also tested with admin rights (which I shoud have tried before, right?), same thing.

Noticed that the command \lc also returns the temp file error. Despite that, the command works. The error message is:

Error detected while processing function vimtex#compiler#clean[1]..31[15]..vimtex#process#run[5]..173[5]..178:
line    2:
E484: Can't open file C:\Users\julia\AppData\Local\Temp\VIoE574.tmp

Small edit: I ran through the compiler.vim and noticed some abort funcionalities that call for the stop command, which I believe should close the perl interpreter and latexmk.exe. Also not working. In reality I've been conducting all these tests and closing Perl.exe by hand.

Small Rant

I really dont know why I'm bothering so much with this, since I'm changing from windows to arch linux in the near future... windows is full of telemetry, BSOD's and this type of nonsense.

lervag commented 6 years ago

Yes, it persists. but initially gives the "selected viewer is not executable!" warning.

I see, in this case you could set the first option just to prevent this warning.

From your :scriptnames output, it seems that things are as they should be.

I got angry and just clean reinstalled vim due to other weird behavior. It was as painful as it sounds. In the end, I reinstalled vim-plug and vimtex, got hopeful, same problem, got frustrated again.

I'm sorry about this, and I wish I was able to solve your problem more easily!

Also tested with admin rights (which I shoud have tried before, right?), same thing.

That seems sensible, I agree. And strange that things still do not work.

Noticed that the command \lc also returns the temp file error. Despite that, the command works. The error message is: ...

Small edit: I ran through the compiler.vim and noticed some abort funcionalities that call for the stop command, which I believe should close the perl interpreter and latexmk.exe. Also not working. In reality I've been conducting all these tests and closing Perl.exe by hand.

Small Rant I really dont know why I'm bothering so much with this, since I'm changing from windows to arch linux in the near future... windows is full of telemetry, BSOD's and this type of nonsense.

If you search through previous issues, you will quickly see that I have my share of rants for Windows related issues. Unfortunately, I have still not had a user that has enough understanding of how things work on Windows to help me make vimtex fool proof. My own understanding and knowledge is not enough, and I am not interested in spending too much time on such issues. I don't use Windows myself for anything but Word and Excel at work.

Although I don't think it will help, you should read :help vimtex-faq-windows.


So, what do we do? I have no idea what more to try. I see nothing wrong with your configuration or system (except that it is not running Linux), and I can't find anything else than what I've already suggested. As such, I want to close the issue as unresolved, unless you have some other ideas yourself.

hicsuntdragons commented 6 years ago

Unfortunately, I have still not had a user that has enough understanding of how things work on Windows to help me make vimtex fool proof.

As I investigate this, I am starting to deduce the problem is on a lower level on my installation. Now i get errors while running vim-plug and when using utisnips, but never with built-in features, which suggests the interaction between vim and vim-plug is broken.

If you search through previous issues, you will quickly see that I have my share of rants for Windows related issues...

I use windows at this point only because of tradition. I got to a point where even my editing software is open source and initially developed for linux xD, I'm just waiting on a new ssd I bought to make the final change.

So, what do we do? I have no idea what more to try.

Well, is not a fatal error, since everything is (somewhat) usable, although preceeded of these strange errors.... also I have another machine with a working installation of neovim and the vimtex plugin. Also, this problem will soon desappear of my life xD. Finally, this seems to be a very rare occurence, since I found no docummented issue. I say we rest for now.

Final Thanks

lervag, thanks for taking your time to try and troubleshoot this with me. Your dedication to this project is quite amazing, as I saw when I read the other posts. Keep up the good work! :)

lervag commented 6 years ago

Thank you for the kind words. I enjoy working with this project, and it makes me happy that other people find it useful. :)

So, I'm closing this. If you should learn something that might help solve the issue, then please feel free to reopen!