Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:VimtexCompile in WSL with neovim and okular create not a --unique instance #1720

Closed
vincentbenzo opened this issue Jun 18, 2020 · 9 comments
Labels

Comments

@vincentbenzo
Copy link

vincentbenzo commented Jun 18, 2020

Hello again :)
Issue
When I first compile using :VimtexCompile or \ll I have an okular information window saying: "There is already a unique Okular instance running. This instance won't be the unique one." If I click ok the pdf appears. When I change something in the minimal.tex the pdf is updated in the same instance.
However when I use \lv I have the same information window appearing from okular. If I press OK a second instance open at the right spot.
I was expecting to have the same pdf moving to the right not an a new pdf to be opened on the right spot.

minimal.vim

" Plugins will be downloaded under the specified directory.
call plug#begin(stdpath('data') . '/plugged')

" Declare the list of plugins.
"
" Plugin for better LaTeX experience
Plug 'lervag/vimtex'
" Plugin to add servername option to Neovim since it doesn't support out of
" the box the option
Plug 'mhinz/neovim-remote'
" List ends here. Plugins become visible to Vim after this call.
call plug#end()

" VIMTEX related
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--noraise --unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
let g:vimtex_compiler_progname = 'nvr' " Enable nvr for neovim to have backsearch

minimal.tex

\documentclass{minimal}
\begin{document}
Hello world!
\end{document}

Output from VimtexInfo

System info
  OS: Linux 4.4.0-17763-Microsoft
  Vim version: NVIM v0.3.4
  Has clientserver: true
  Servername: /tmp/mynvimserver

vimtex project: minimal
  base: minimal.tex
  root: /home/vincent
  tex: /home/vincent/minimal.tex
  out: /home/vincent/minimal.pdf
  log: /home/vincent/minimal.log
  aux: /home/vincent/minimal.aux
  fls: /home/vincent/minimal.fls
  main parser: current file verified
  compiler: latexmk
    backend: nvim
    output: /tmp/nvimmwqvfu/0
    configuration:
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
  viewer: General
  qf: LaTeX logfile
    config:
      packages:
        default: 1
      default: 1
  document class: article

Edit: It seems related to #1374 but on debian on wsl

@lervag
Copy link
Owner

lervag commented Jun 18, 2020

Hello again :)

Hi :)

Issue
When I first compile using :VimtexCompile or \ll I have an okular information window saying: "There is already a unique Okular instance running. This instance won't be the unique one." If I click ok the pdf appears. When I change something in the minimal.tex the pdf is updated in the same instance.
However when I use \lv I have the same information window appearing from okular. If I press OK a second instance open at the right spot.
I was expecting to have the same pdf moving to the right not an a new pdf to be opened on the right spot.

This is not really a vimtex issue, as there is no specific Okular feature in vimtex. The interface to Okular is specified through the options for the general viewer. However, I can try to help figure things out.

" Plugins will be downloaded under the specified directory.
call plug#begin(stdpath('data') . '/plugged')

" Declare the list of plugins.
"
" Plugin for better LaTeX experience
Plug 'lervag/vimtex'
" Plugin to add servername option to Neovim since it doesn't support out of
" the box the option
Plug 'mhinz/neovim-remote'
" List ends here. Plugins become visible to Vim after this call.
call plug#end()

The following is better as it is even more minimal:

set nocompatible
let &rtp = stdpath('data') . '/plugged/vimtex,' . &rtp
let &rtp .= ',' . stdpath('data') . '/plugged/vimtex/after'
filetype plugin indent on
syntax enable
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--noraise --unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
let g:vimtex_compiler_progname = 'nvr' " Enable nvr for neovim to have backsearch

This is what I mean about Okular not having a specific vimtex interface.

Note that g:vimtex_compiler_progname is not necessary, as it should already be specified to nvr by default (if nvr exists/is available).

So, to debug this, I would try to replicate the behaviour outside Vim. That is, first, compile your project with latexmk (e.g. from within vimtex). Next, open a terminal at the same location and test the capabilities:

okular --noraise --unique file:test.pdf#src:100test.tex

Of course, change the filenames test.pdf and test.tex and the line number (100) to something appropriate to your test.

Does it give any warnings in the terminal? Can you replicate the warning message?

@vincentbenzo
Copy link
Author

WOW this is a great day of solving computer pain point !!!
It is working now !
I feel like a LFS guy with your hint, like I could solve all the errors and warnings!
Thank you VERY MUCH !

I am just going to document the solution in case someone is looking for it. If you think it is not the place you can delete or move it.
I add errors and warnings when I launched okular from outside vim.
First error :

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

Solved by : sudo apt-get install mesa-utils
Found from this post

Second error/warning:

"Session bus not found\nTo circumvent this problem try the following command (with Linux and bash)\nexport $(dbus-launch)"

Solved by : sudo apt install dbus-x11

@lervag
Copy link
Owner

lervag commented Jun 18, 2020

WOW this is a great day of solving computer pain point !!!
It is working now !
I feel like a LFS guy with your hint, like I could solve all the errors and warnings!
Thank you VERY MUCH !

Great, I'm happy to hear it! And it's of course no problem that you've documented the solution, I'm all for sharing! :)

@xyecoding
Copy link

Hello, I also find this problem on my WSL. The information, "There is already a unique Okular instance running. This instance won't be the unique one" occur even when I just run 'okular --unique'.
I wonder how you fixed this.

@lervag
Copy link
Owner

lervag commented Feb 28, 2022

Did you try the solutions proposed by @vincentbenzo?

@xyecoding
Copy link

xyecoding commented Feb 28, 2022

Did you try the solutions proposed by @vincentbenzo?

yes. I run 'sudo apt-get install mesa-utils' and sudo apt install dbus-x11. However, the problem still remian. I guess its a problem of okular itself on wsl.

@lervag
Copy link
Owner

lervag commented Feb 28, 2022

I see. I'm sorry to say I don't have anything more to say to help here except what I wrote to @vincentbenzo. :\

@xyecoding
Copy link

sudo apt install dbus-x11

I see. I'm sorry to say I don't have anything more to say to help here except what I wrote to @vincentbenzo. :\

I figured it out!
I found it is the issue of wsl system. When I installed ubuntu 20.04 LTS wsl by Microsoft Store, the problem remained. However, When I install it manually by LxRunOffline, okular performs correctly.

@lervag
Copy link
Owner

lervag commented Feb 28, 2022

Great, happy to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants