lervag / vimtex

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

4 filenames specified #1795

Closed JohanRibbing closed 3 years ago

JohanRibbing commented 4 years ago

Issue Preface: I am very sorry if this issue is incorrectly submitted, just tell me and i will fix it ASAP. Thank you for your patience.

I cannot compile a simple test.tex doucment. I get error

vimtex: Compiler did not start successfully!

With logs about wrong number of filenames.

Output from :VimtexCompileOutput

latexmk: security risk: running with elevated privileges
Unquoted string "echo" may clash with future reserved word at (eval 10) line 1.
Unquoted string "echo" may clash with future reserved word at (eval 11) line 1.
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.

_**Latexmk: Need to specify exactly one filename for preview-continuous mode
    but 4 were specified**_
Use
   latexmk -help
to get usage information

vimrc

inoremap jk <Esc>

autocmd FileType python map <buffer> <F9> :w<CR>:exec '!python' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F9> <esc>:w<CR>:exec '!python' shellescape(@%, 1)<CR>

let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

set conceallevel=1

let g:tex_flavor='latex'
let g:tex_conceal='abdmg'
let g:vimtex_quickfix_mode=0
let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
    \ = '-reuse-instance -forward-search @tex @line @pdf'

Additional information If i compile manually from git bash with

latexmk test.tex -pdf

Then \lv works fine but \ll still gives the exact same error.

minimal.tex

\documentclass{minimal}

\begin{document}
blablabla
\end{document}

Commands/Input \ll

Observed Behaviour Compilation does not start succesfully

Expected Behaviour Compilation starts successfully

Output from VimtexInfo

System info
  OS: LAPTOP-KNT77K0P (Microsoft Windows 10 Home)
  Vim version: VIM 8.2 (1-869)
  Has clientserver: false

vimtex project: test
  base: test.tex
  root: /c/Users/Johan
  tex: /c/Users/Johan/test.tex
  out: 
  log: 
  aux: 
  fls: 
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
  viewer: General
  qf: LaTeX logfile
    addqflist: 56
    fix_paths: 57
    set_errorformat: 55
  document class: minimal

EDIT: added Additional information

lervag commented 4 years ago

Preface: I am very sorry if this issue is incorrectly submitted, just tell me and i will fix it ASAP. Thank you for your patience.

Will do. I took the liberty of cleaning your post a little bit.

Output from :VimtexCompileOutput

Thanks, this is useful information! Notice that :VimtexInfo will show the command used by \ll, so can you please do :VimtexInfo after \ll and present the output here?

Some comments to your vimrc file (I've refined it and added comments "inline").

" This part shoud preferably come first, and don't apply plugin configuration
" until after plug#end()
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

" The following lines are not relevant for the current issue, and thus you
" don't need to include them (I think; feel free to remove them and check if
" you can still reproduce)
inoremap jk <Esc>
autocmd FileType python map <buffer> <F9> :w<CR>:exec '!python' shellescape(@%, 1)<CR>
autocmd FileType python imap <buffer> <F9> <esc>:w<CR>:exec '!python' shellescape(@%, 1)<CR>
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
set conceallevel=1

" These could be relevant (but probably not)
let g:tex_flavor='latex'
let g:tex_conceal='abdmg'
let g:vimtex_quickfix_mode=0
let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
    \ = '-reuse-instance -forward-search @tex @line @pdf'

When you've tested the \ll command, did you do it with vim -u minivimrc mwe.tex?

JohanRibbing commented 4 years ago

First of all, thank you for the quick response! Really awesome.

When you've tested the \ll command, did you do it with vim -u minivimrc mwe.tex?

No, i dont know what the -u flag does, what minivimrc is or what the mwe.tex file is. I only started using vim a few months ago, actually want to get started with vimtex as another way of getting more time in vim.

Running that from the terminal gives

E282: Cannot read from "minivimrc"

Did i misunderstand the question?

Output from :VimtexInfo after running \ll

System info
  OS: LAPTOP-KNT77K0P (Microsoft Windows 10 Home)
  Vim version: VIM 8.2 (1-869)
  Has clientserver: false

vimtex project: test
  base: test.tex
  root: /c/Users/Johan
  tex: /c/Users/Johan/test.tex
  out: /c/Users/Johan/test.pdf
  log: /c/Users/Johan/test.log
  aux: /c/Users/Johan/test.aux
  fls: /c/Users/Johan/test.fls
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    job: process 1211 dead
    pid: 1211
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex'
  viewer: General
  qf: LaTeX logfile
    addqflist: 56
    fix_paths: 57
    set_errorformat: 55
  document class: minimal
lervag commented 4 years ago

First of all, thank you for the quick response! Really awesome.

No problem, I'm happy if I'm able to help :)

No, i dont know what the -u flag does, what minivimrc is or what the mwe.tex file is. I only started using vim a few months ago, actually want to get started with vimtex as another way of getting more time in vim.

Ah, I see. Let me try to explain, then:

Output from :VimtexInfo after running \ll ... cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex'

You previously tested that latexmk -pdf test.tex works as expected from you git bash session. Can you test the command used by vimtex as well? That is, run

max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex'

It should work. But you could also try this:

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc 'test.tex'
JohanRibbing commented 4 years ago

Ok, so: with minimal config and file, running vim -u minivimrc mwe.tex and then \ll i got the same exact same error message.

Running max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex' Also gives the same error.

Running latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc 'test.tex'

Seems to work fine. The file is compiled, opened in SumatraPDF and when changing and writing to test.tex, the visible pdf automatically updates.

EDIT: below So if i understand correctly, \ll makes vimtex run the first version of calling latexmk and that results in the "4 filenames" bug. What is the difference between that and the second version, which worked?

lervag commented 4 years ago

Running max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex' Also gives the same error.

Ok, this "simplifies" things in that we can look for what in the command is failing and try to fix in from the terminal first.

So if i understand correctly, \ll makes vimtex run the first version of calling latexmk and that results in the "4 filenames" bug.

Yes, correct.

What is the difference between that and the second version, which worked?

The second version was simplified: I removed some of the arguments:

max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex'
                    latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc                                                                                                                                                                           'test.tex'

Can you next test with this:

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' 'test.tex'
JohanRibbing commented 4 years ago

Ok now it got interesting. Running the last version you suggested gives the same error but 2 filenames instead of 4. The first version still gives the 4 filenames error.

Inputs and outputs $ latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' 'test.tex' Rc files read: NONE Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.

Latexmk: Need to specify exactly one filename for preview-continuous mode but 2 were specified Use latexmk -help to get usage information


$ max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "SumatraPDF reuse-instance"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'test.tex' Unquoted string "echo" may clash with future reserved word at (eval 10) line 1. Unquoted string "echo" may clash with future reserved word at (eval 11) line 1. Rc files read: NONE Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.

Latexmk: Need to specify exactly one filename for preview-continuous mode but 4 were specified Use latexmk -help to get usage information

lervag commented 4 years ago

Ok now it got interesting. Running the last version you suggested gives the same error but 2 filenames instead of 4. The first version still gives the 4 filenames error.

Yes, I agree. This is quite strange. It seems, for some reason, that the -e option is not properly "understood". Can you try to switch the quotation types, i.e.:

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e "$pdf_previewer = 'SumatraPDF reuse-instance'" 'test.tex'

Can you also type latexmk -help and check if it lists the -e option as a valid option? On my end, it is listed as follows:

> latexmk -help
Latexmk 4.69a: Automatic LaTeX document generation routine

Usage: latexmk [latexmk_options] [filename ...]

  Latexmk_options:
   -aux-directory=dir or -auxdir=dir
   ...
   ...
   -dvi-  - turn off required dvi
   -e <code> - Execute specified Perl code (as part of latexmk start-up
               code)
JohanRibbing commented 4 years ago

I'll just keep copy pasting from the terminal, that seems clearest.

$ latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e "$pdf_previewer = 'SumatraPDF reuse-instance'" 'test.tex'
Latexmk: Stopping because executing following code from command line
     = 'SumatraPDF reuse-instance'
gave an error:
    syntax error at (eval 9) line 1, near "="
$ latexmk --help
Latexmk 4.69a: Automatic LaTeX document generation routine

Usage: latexmk [latexmk_options] [filename ...]

  Latexmk_options:
   -aux-directory=dir or -auxdir=dir
                 - set name of directory for auxiliary files (aux, log)
                 - Currently this only works with MiKTeX
   -bibtex       - use bibtex when needed (default)
   -bibtex-      - never use bibtex
..
...
 -dvi-  - turn off required dvi
   -e <code> - Execute specified Perl code (as part of latexmk start-up
               code)
lervag commented 4 years ago

Ok, this is very strange. I'm sorry to say I only barely use Windows, and so I am not able to reproduce this. Did you say you are running this in a git bash terminal? Can you explain more precisely what this means?

Can you try this one?

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$success_cmd = "echo vimtex_compiler_callback_success"' 'test.tex'

Does it have the same error?

JohanRibbing commented 4 years ago

Ok, this is very strange. I'm sorry to say I only barely use Windows, and so I am not able to reproduce this. Did you say you are running this in a git bash terminal? Can you explain more precisely what this means?

Can you try this one?

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$success_cmd = "echo vimtex_compiler_callback_success"' 'test.tex'

Does it have the same error?

This gives the error "... 2 were specified ..."

As for git BASH i think it just emulates BASH for windows. Has worked fine for everything so far.

lervag commented 4 years ago

How about this?

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -e '$success_cmd = "echo vimtex_compiler_callback_success"' -pvc 'test.tex'
lervag commented 4 years ago

What is the output of this?

echo latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -e '$success_cmd = "echo vimtex_compiler_callback_success"' -pvc 'test.tex'
JohanRibbing commented 4 years ago
$ latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -e '$success_cmd = "echo vimtex_compiler_callback_success"' -pvc 'test.tex'
latexmk: security risk: running with elevated privileges
Unquoted string "echo" may clash with future reserved word at (eval 9) line 1.
Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.

Latexmk: Need to specify exactly one filename for preview-continuous mode
    but 2 were specified
Use
   latexmk -help
to get usage information
$ echo latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -e '$success_cmd = "echo vimtex_compiler_callback_success"' -pvc 'test.tex'
latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -e $success_cmd = "echo vimtex_compiler_callback_success" -pvc test.tex
lervag commented 4 years ago

How about this?

latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e "$success_cmd = \"echo vimtex_compiler_callback_success\"" test.tex
JohanRibbing commented 4 years ago

$ latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e "$success_cmd = \"echo vimtex_compiler_callback_success\"" test.tex latexmk: security risk: running with elevated privileges Unquoted string "echo" may clash with future reserved word at (eval 9) line 1. Latexmk: Stopping because executing following code from command line = echo gave an error: syntax error at (eval 9) line 1, near "="

lervag commented 4 years ago

No, you must escape the "inner" quotes, i.e. \"echo ... \".

JohanRibbing commented 4 years ago

Sorry, must have copied wrong

$ latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e "$success_cmd = \"echo vimtex_compiler_callback_success\"" test.tex Unquoted string "echo" may clash with future reserved word at (eval 9) line 1. Latexmk: Stopping because executing following code from command line = echo gave an error: syntax error at (eval 9) line 1, near "="

lervag commented 4 years ago

Ok, so this is the output when you write ... -e "$success_cmd = \"echo ...\"" test.tex? Again, note that the "inner" quotes are escaped: \" as opposed to just ".

I'm don't really know what to do next. This is really strange. The command should work, and I have never heard of this issue before. :\

JohanRibbing commented 4 years ago

Alright, fair enough, it's probably best for my sake as well to stop pouring time into this. Thank you for all the help anyway! I really did not expect such dedicated attention. I guess at least there is no issue with vimtex right? So that is good at least :D

lervag commented 4 years ago

Alright, fair enough, it's probably best for my sake as well to stop pouring time into this. Thank you for all the help anyway! I really did not expect such dedicated attention.

My pleasure. I'm dissappointed I couldn't be of more help, though. By the way, did you read :help vimtex-faq-windows? There are some links to older issues that may be helpful. Also, check :help vimtex-faq-wsl; perhaps you could try to use vim+vimtex inside wsl?

I guess at least there is no issue with vimtex right? So that is good at least :D

Sort of. But you are using the same version of latexmk as me and it "should work". I'm thinking it might be something about the terminal or shell you are using. But as I hinted at earlier, I'm not really a Windows expert, and I don't know specifically what to suggest going forwards.

I guess I never really asked how you use Vim on Windows. That is, are you running Vim inside a git bash? How did you install it? Did you try with standard gVim for Windows?

JohanRibbing commented 4 years ago

H! I'm back again. I have got wsl and ubuntu for windows going. Now latexmk works, \ll works and the only thing left is to be able to view pdfs. May I ask if you know a pdf viewer that works with vimtex from within ubuntu for windows? Zathura, okular, and mupdf give errors like cannot open display

lervag commented 4 years ago

May I ask if you know a pdf viewer that works with vimtex from within ubuntu for windows? Zathura, okular, and mupdf give errors like cannot open display

Yes, sure. I think Zathura, okular, and mupdf should all work, but you need to install an X server. I think the current "best practise" is to install VcXsrv. Make sure to start it, then afterwards I think things should work. You might need to specify the DISPLAY environment variable in your .bashrc.

Perhaps this blog post can be of help? It was among the first hits when I searched for wsl + vcxsrv.