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

Viewer cannot find Zathura window ID on macOS #1737

Closed
flimofly opened this issue Jul 6, 2020 · 36 comments
Closed

Viewer cannot find Zathura window ID on macOS #1737

flimofly opened this issue Jul 6, 2020 · 36 comments
Labels
bug os-mac MacOS / OSX

Comments

@flimofly
Copy link

flimofly commented Jul 6, 2020

Issue
In Neovim on MacOS, when pressing \lv to trigger :VimtexView, I get error message vimtex: Viewer cannot find Zathura window ID!. The Zathura window does not get a xwin id. xdotool is installed.

minimal.vim

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

let g:vimtex_view_method = 'zathura'

minimal.tex

\documentclass{article}
\begin{document}

\title{Big Title}
\author{Author Name}
\maketitle

\section{Chapter Title}
Consectetuer adipiscing elit. Aenean commodo ligula eget dolor.

\section{Chapter next}
Lorem ipsum dolor sit amet,

\end{document}

Output from VimtexCompileOuput

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.
Viewing pdf
======= Need to update make_preview_continuous for target files
Latexmk: I have not found a previewer that is already running. 
   So I will start it for 'mwe.pdf'
------------
Latexmk: All targets (mwe.pdf) are up-to-date
For rule 'view', running '&if_source(  )' ...
------------
Running 'start zathura  -x "nvr --servername /var/folders/bv/ctdkmjy5583dgsks5z4tf8r40000gn/T/vimr_E4615521-7C8A-4FBF-812D-F4D6EB8D1DBC.sock --remote +%{line} %{input}" "mwe.pdf"'
------------
------------
Running 'echo vimtex_compiler_callback_success'
------------
vimtex_compiler_callback_success

Commands/Input

  • Open source file
  • Compile with \ll
  • Put cursor within body of source file and do \lv or :VimtexView

Observed Behaviour
Error message appears

Expected Behaviour
Expect window to shift and passage to be highlighted in Zathura

Output from VimtexInfo

System info
  OS: Mac OS X 10.15.5 (19F101)
  Vim version: NVIM v0.4.3
  Has clientserver: true
  Servername: /var/folders/bv/ctdkmjy5583dgsks5z4tf8r40000gn/T/vimr_B34B0D20-0B2F-4D8E-B5B4-8BB5EBCAC57A.sock

vimtex project: mwe
  base: mwe.tex
  root: /Users/Timothy/Desktop/mwe
  tex: /Users/Timothy/Desktop/mwe/mwe.tex
  out: /Users/Timothy/Desktop/mwe/mwe.pdf
  log: /Users/Timothy/Desktop/mwe/mwe.log
  aux: /Users/Timothy/Desktop/mwe/mwe.aux
  fls: /Users/Timothy/Desktop/mwe/mwe.fls
  main parser: current file verified
  compiler: latexmk
    backend: nvim
    output: /var/folders/bv/ctdkmjy5583dgsks5z4tf8r40000gn/T/nvim3vxPQp/0
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    pid: 1516
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0"' -e '$pdf_previewer = "zathura  -x \"nvr --servername /var/folders/bv/ctdkmjy5583dgsks5z4tf8r40000gn/T/vimr_B34B0D20-0B2F-4D8E-B5B4-8BB5EBCAC57A.sock --remote +\%{line} \%{input}\" \%S"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'mwe.tex'
  viewer: Zathura
    xwin id: 0
    process: 
      pid: -
      cmd: zathura -x "nvr --servername /var/folders/bv/ctdkmjy5583dgsks5z4tf8r40000gn/T/vimr_B34B0D20-0B2F-4D8E-B5B4-8BB5EBCAC57A.sock --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 11:14:'/Users/Timothy/Desktop/mwe/mwe.tex'  '/Users/Timothy/Desktop/mwe/mwe.pdf' >/dev/null 2>&1 &
  qf: LaTeX logfile
    config: 
      packages: 
        default: 1
      default: 1
  document class: article

Edit by @lervag: Remove unnecessary options from minimal vimrc.

@lervag
Copy link
Owner

lervag commented Jul 12, 2020

In #1735 I got the impression that this issue was resolved. Did I misunderstand?

@lervag lervag added the os-mac MacOS / OSX label Jul 12, 2020
@flimofly
Copy link
Author

A different issue lay at the basis of that one. Once I resolved that, I got the error message that's in the title of this issue. For future reference it seemed more clear to create a separate issue for both.

@lervag
Copy link
Owner

lervag commented Jul 14, 2020

Ok. Have you tried the commands from a terminal? That is:

  1. Open the mwe.pdf in Zathura with a command like this from a terminal in the same location as the file: zathura -x "nvr --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 11:14:mwe.tex mwe.pdf
  2. Now do xdotool search --class Zathura. What's the output?

@flimofly
Copy link
Author

Thanks. Nothing happens when I run that command in Terminal. Zathura doesn't open and the terminal doesn't give me a new prompt.

@lervag
Copy link
Owner

lervag commented Jul 22, 2020

Ok, then try simply zathura mwe.pdf. Does that work?

Do you have Zathura with libsynctex support? Which version of Zathura? What's the output of zathura --help?

@flimofly
Copy link
Author

flimofly commented Jul 23, 2020

That command works: the pdf opens as expected.
I reinstalled zathura with synctex just to be sure but nothing changed.
Output of zathura --help is this:

  zathura [OPTION…]  [file1] [file2] [...]

Help Options:
  -h, --help                           Show help options

Application Options:
  -e, --reparent=xid                   Reparents to window specified by xid (X11)
  -c, --config-dir=path                Path to the config directory
  -d, --data-dir=path                  Path to the data directory
  --cache-dir=path                     Path to the cache directory
  -p, --plugins-dir=path               Path to the directories containing plugins
  --fork                               Fork into the background
  -w, --password=password              Document password
  -P, --page=number                    Page number to go to
  -l, --log-level=level                Log level (debug, info, warning, error)
  -v, --version                        Print version information
  -x, --synctex-editor-command=cmd     Synctex editor (forwarded to the synctex command)
  --synctex-forward=position           Move to given synctex position
  --synctex-pid=pid                    Highlight given position in the given process
  --mode=mode                          Start in a non-default mode

@lervag
Copy link
Owner

lervag commented Jul 23, 2020

Good, but you did not respond to all of my questions:

Ok. Have you tried the commands from a terminal? That is:

  1. Open the mwe.pdf in Zathura with a command like this from a terminal in the same location as the file: zathura -x "nvr --remote-expr "vimtex#view#reverse_goto(%{line}, '%{input}')"" --synctex-forward 11:14:mwe.tex mwe.pdf
  2. Now do xdotool search --class Zathura. What's the output?

@flimofly
Copy link
Author

flimofly commented Jul 30, 2020

My apologies for the late reply (holiday).

When I copy paste the first command in a Terminal I now get:
zsh: unknown file attribute: { Other times it runs but nothing happens at all.

When I subsequently type the xdotool command I don't get anything. When I instead do zathura mwe.pdf, zathura correctly opens the PDF. When I then run the xdotool command there is no output either.

@lervag
Copy link
Owner

lervag commented Jul 30, 2020

Thanks. I believe the zathura command is correct, except for some escaping. You could try this:

zathura -x 'nvr --remote-expr "vimtex#view#reverse_goto(%{line}, ''%{input}'')"' ...

However, I think the real problem is that xdotool is not working as expected. Before we proceed on the Vim side of things, we need to make sure we can start Zathura, then use xdotool from a terminal to obtain the X window ID.

So, for now, simplify:

  1. Open a pdf in Zathura: zathura mwe.pdf & (last & to make it go to background).

  2. Now again, confirm that xdotool search --class Zathura does not give any output.

  3. Install xprop or xwininfo, if necessary.

  4. Run xprop to get the window properties from the Zathura window. Try with xwininfo as well. What's the output?

I've already mentioned that this seems related to #1719. Can you please read that thread again, especially the comments from June 17 and later? E.g. this comment seems relevant.

@flimofly
Copy link
Author

  1. I can open the pdf but the & doesn't put the process in the background. It does give me what looks like a PID, e.g.
    [1] 18412
  2. xdotool search --class Zathura gives no output
  3. Running the command xprop and clicking on the zathura window does nothing. Running xwininfo asks me explicitly to click in the zathura window but when I do that nothing happens

I don't know whether this is true on Linux but on macOS zathura does not behave like a normal window. When opened like this it's attached to the Terminal process. I can't close the zathura window separtely, I can only do this by closing the Terminal session.

I've tried to implement the #1719 wrapper script but I don't quite know how to translate this to macOS. Even with sudo I can't just copy that script to /usr/bin/. I also wouldn't know how to check where that folder is in my PATH. Any ideas on how to adapt the instructions in that thread to my system?

@lervag
Copy link
Owner

lervag commented Jul 31, 2020

I've tried to implement the #1719 wrapper script but I don't quite know how to translate this to macOS. Even with sudo I can't just copy that script to /usr/bin/. I also wouldn't know how to check where that folder is in my PATH. Any ideas on how to adapt the instructions in that thread to my system?

Ah, I'm sorry, my mistake. I thought that issue was related to OSX, but it was related to Wayland on Linux. However, this issue is relevant. Could you read the linked comment and see if it helps?

@lervag
Copy link
Owner

lervag commented Jul 31, 2020

Ah, no, sorry. I realize @ktran9891 get's the same message as you. So, it seems noone so far has been able to get Zathura to fully work on OSX. I don't use OSX myself, and I am confident that the issue here is related to the xdotool part. It seems it is not possible to obtain the window ID with xdotool. To solve the issue, you would have to investigate this part, and I'm afraid I am not able to help further with that.

@lervag lervag closed this as completed Jul 31, 2020
@flimofly
Copy link
Author

See fix over at zegervdv/homebrew-zathura

But when I install development branch the zathura window is now correctly seen by window management apps like Magnet but zathura does not open with VimtexCompile (it does open with :! zathura test.pdf & however). Maybe this will work when it's merged into the zathura master?

@danielfalbo
Copy link
Contributor

@flimofly on my machine it already works fine

Screen.Recording.2021-01-11.at.15.37.58.mov

@flimofly
Copy link
Author

@flimofly on my machine it already works fine

Screen.Recording.2021-01-11.at.15.37.58.mov

Oh that's great! Are you also on macOS Big Sur? Is a window ID assigned by xdotool (see :VimtexInfo)? I have no idea what I'm doing wrong. Did you need to install the develop version of zathura with an option to install libsync?

@tbsmn
Copy link

tbsmn commented Jan 11, 2021

I have the same problem with zathura. When i type the cmd from :VimtexInfo in the terminal manually zathura -x "/Applications/MacVim.app/Contents/MacOS/Vim --servername VIM --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 1:1:'/Users/tobiassimon/sandbox/minimal_vimtex/main.tex' '/Users/tbsmn/sandbox/minimal_vimtex/build/main.pdf' >/dev/null 2>&1 &

I get this output:

[1] 42075
[1]  + exit 255   zathura -x  --synctex-forward   > /dev/null 2>&1

Does this help anyone to see whats wrong?

@lervag
Copy link
Owner

lervag commented Jan 11, 2021

@tbsmn Can you try the same, but without >/dev/null 2>&1? That part removes all output/error messages.

@danielfalbo
Copy link
Contributor

danielfalbo commented Jan 11, 2021

@flimofly on my machine it already works fine

Screen.Recording.2021-01-11.at.15.37.58.mov

Oh that's great! Are you also on macOS Big Sur? Is a window ID assigned by xdotool (see :VimtexInfo)? I have no idea what I'm doing wrong. Did you need to install the develop version of zathura with an option to install libsync?

Yeah, I'm on latest macOS, I just followed the instructions on the homebrew-zathura issue

and this is the output of `:VimtexInfo` after starting the compiler
System info
  OS: macOS 11.1 (20C69)
  Vim version: NVIM v0.4.4
  Has clientserver: true
  Servername: /var/folders/3r/_5t4ccxd4gv7j_q14qgnpf3r0000gn/T/nvimwuPAEu/0

vimtex project: main
  base: main.tex
  root: /Users/danielfalbo/Downloads/tmp
  tex: /Users/danielfalbo/Downloads/tmp/main.tex
  out: /Users/danielfalbo/Downloads/tmp/main.pdf
  log: /Users/danielfalbo/Downloads/tmp/main.log
  aux: /Users/danielfalbo/Downloads/tmp/main.aux
  fls: /Users/danielfalbo/Downloads/tmp/main.fls
  main parser: current file
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
    job: 5
    pid: 12015
    cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$new_viewer_always = "0"' -e '$pdf_previewer = "zathura  -x \"/usr/local/Cellar/neovim/0.4.4/bin/nvim --servername /var/folders/3r/_5t4ccxd4gv7j_q14qgnpf3r0000gn/T/nvimwuPAEu/0 --remote +\%{line} \%{input}\" \%S"' -e '$success_cmd = "echo vimtex_compiler_callback_success"' -e '$failure_cmd = "echo vimtex_compiler_callback_failure"' 'main.tex'
  viewer: Zathura
    xwin id: 0
    process: 
      pid: -
      cmd: zathura -x "/usr/local/Cellar/neovim/0.4.4/bin/nvim --servername /var/folders/3r/_5t4ccxd4gv7j_q14qgnpf3r0000gn/T/nvimwuPAEu/0 --remote-expr \"vimtex#view#reverse_goto(%{line}, '%{input}')\"" --synctex-forward 51:1:'/Users/danielfalbo/Downloads/tmp/main.tex'  '/Users/danielfalbo/Downloads/tmp/main.pdf' >/dev/null 2>&1 &
  qf: LaTeX logfile
    root: /Users/danielfalbo/Downloads/tmp
    addqflist: 62
    errorformat_saved: 
    fix_paths: 63
    main: /Users/danielfalbo/Downloads/tmp/main.tex
    set_errorformat: 61
  document class: 
  packages:
    amsbsy
    amsfonts
    amsgen
    amsmath
    amsopn
    amssymb
    amstext
    amsthm
    array
    atbegshi
    atveryend
    auxhook
    bigintcalc
    bitset
    bookmark
    booktabs
    calc
    enumitem
    epigraph
    epstopdf-base
    eso-pic
    etexcmds
    everyshi
    fontawesome
    fontenc
    fourier
    fourier-orns
    fouriernc
    geometry
    gettitlestring
    graphics
    graphicx
    hycolor
    hyperref
    ifluatex
    ifmtarg
    iftex
    ifthen
    ifvtex
    ifxetex
    import
    infwarerr
    intcalc
    keyval
    kvdefinekeys
    kvoptions
    kvsetkeys
    letltxmacro
    listings
    lmodern
    lscape
    lstmisc
    ltxcmds
    microtype
    nag
    nameref
    nextpage
    pdfescape
    pdflscape
    pdfpages
    pdftexcmds
    pgf
    pgfcomp-version-0-65
    pgfcomp-version-1-18
    pgfcore
    pgffor
    pgfkeys
    pgfmath
    pgfrcs
    pgfsys
    refcount
    rerunfilecheck
    textcomp
    tikz
    transparent
    trig
    uniquecounter
    url
    xcolor
    xifthen

@flimofly
Copy link
Author

@tbsmn Can you try the same, but without >/dev/null 2>&1? That part removes all output/error messages.

When I do that, I get error: Built without synctex support, but synctex specific option was specified.

But I can't find the precise formulation to install with synctex support via brew in the documentation. Does anyone remember it?

@danielfalbo
Copy link
Contributor

zegervdv/zathura/zathura --with-synctex

@flimofly
Copy link
Author

flimofly commented Jan 12, 2021 via email

@tbsmn
Copy link

tbsmn commented Jan 12, 2021

@tbsmn Can you try the same, but without >/dev/null 2>&1? That part removes all output/error messages.

When I do that I get this error:

error: Could not connect to session bus: Error when creating the command line »dbus-launch --autolaunch=8b1580da9b5b98d21dde03ed5e8470ff --binary-syntax --close-stderr«: The child process was terminated with status 1
error: Got no usable data from SyncTeX or D-Bus failed in some way.

When I run dbus-launch --autolaunch=8b1580da9b5b98d21dde03ed5e8470ff I get:
Autolaunch requested, but X11 support not compiled in. Cannot continue.
I installed dbus from homebrew, any idea how i can get it with X11 support compiled?

@flimofly Is it working for you now? Could you post the exact homebrew commands you used to install zathura to make it work?

@lervag
Copy link
Owner

lervag commented Jan 12, 2021

I'm sorry that I can't be of much more help here, @tbsmn; but I'm glad to see some progress here. I would be very happy if the result of this discussion can be an update to the docs with a simple and consise recipe to make Zathura work on OSX.

@flimofly
Copy link
Author

flimofly commented Jan 12, 2021

Could you post the exact homebrew commands you used to install zathura to make it work?

It's working now. I did:

$ brew uninstall zathura-pdf-poppler
$ brew uninstall zathura
$ brew install zathura --HEAD --with-synctex
$ brew install zathura-pdf-poppler
$ mkdir -p $(brew --prefix zathura)/lib/zathura
$ ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib

Note that before I had installed 'xdotool' via brew and also XQuartz. I had also followed the instructions on this website to get XQuartz to work with XTEST. I wonder whether XQuartz is necessary at all?

@danielfalbo
Copy link
Contributor

On my machine, everything's ok without XQuartz so I guess it's not necessary 👍

@tbsmn
Copy link

tbsmn commented Jan 12, 2021

@flimofly Thanks. I did the exact same install, but it is not working I get the same error as before.

error: Could not connect to session bus: Error when creating the command line »dbus-launch --autolaunch=8b1580da9b5b98d21dde03ed5e8470ff --binary-syntax --close-stderr«: The child process was terminated with status 1
error: Got no usable data from SyncTeX or D-Bus failed in some way.

xdotool and XQuartz work with XTEST. But thanks for that tipp.

Any ideas how I could debug this?

@flimofly
Copy link
Author

@tbsmn Unfortunately I don't have a clue. I looked at an earlier issue that I had with dbus but that was something different so won't help here.

@danielfalbo Does forward search work for you? I see in your VimtexInfo output that xwin = 0. So if you do :VimtexView, you also still get the error Viewer cannot find Zathura window ID! I presume?

@flimofly
Copy link
Author

@tbsmn

Hadn't tried this before because Zathura did open correctly but when I paste the command from VimtexInfo in a separate Terminal window, I now get a similar error that is also dbus related:

error: Could not connect to session bus: Cannot spawn a message bus without a machine-id: Unable to load /usr/local/var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/usr/local/var/lib/dbus/machine-id”: No such file or directory
error: Got no usable data from SyncTeX or D-Bus failed in some way.

@tbsmn
Copy link

tbsmn commented Jan 12, 2021

@flimofly OK so opening and refreshing is working. Same here. But fordward an backward search is an issue (example :VimtexView).
I think this may be related to this Issue: zegervdv/homebrew-zathura#50

@lervag
Copy link
Owner

lervag commented Jan 13, 2021

@danielfalbo Does forward/backward search work for you, or do you have the same issue?

@flimofly
Copy link
Author

Forward and backward search are working now for both @tbsmn and me on latest version of macOS.

See further troubleshooting over at zegervdv/homebrew-zathura

@lervag
Copy link
Owner

lervag commented Jan 13, 2021

Ah, nice! Would you care to provide an updated summary of what is required, then I can add it to the docs?

@tbsmn
Copy link

tbsmn commented Jan 14, 2021

I will give it a try:

  1. Run brew install dbus (if already installed) brew reinstall dbus
  2. Add export DBUS_SESSION_BUS_ADDRESS='unix:path='$DBUS_LAUNCHD_SESSION_BUS_SOCKET to .zshrc
  3. Changed the value of <auth><\auth> in /usr/local/opt/dbus/share/dbus-1/session.conf from EXTERNAL to DBUS_COOKIE_SHA1
  4. Run brew services start dbus
  5. Install Zathura
# unlink installed zathura and girara
brew unlink girara
brew unlink zathura

# install HEAD
brew install girara --HEAD
$ brew uninstall zathura-pdf-poppler
$ brew uninstall zathura
$ brew install zathura --HEAD --with-synctex
$ brew install zathura-pdf-poppler
$ mkdir -p $(brew --prefix zathura)/lib/zathura
$ ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib
  1. Reboot

Credits go to @ROBERT-MICHAEL who figured out the dbus part.
@flimofly am I missing something?

lervag added a commit that referenced this issue Jan 16, 2021
@lervag
Copy link
Owner

lervag commented Jan 16, 2021

Thanks! I've tried to add a section :help vimtex-faq-zathura-osx that I hope is helpful. Reg. step 5, do you need sudo or change user to root? Why $ infront of the last commands? Do you need brew unlink if you did not already install Zathura before?

@flimofly
Copy link
Author

Thanks both!
No need for sudo or root user. (Terminal noob here, but doesn't the $ just mean normal user?)
brew unlink is not necessary when zathura is not installed.

lervag added a commit that referenced this issue Jan 16, 2021
@CharmingZh
Copy link

I will give it a try:

  1. Run brew install dbus (if already installed) brew reinstall dbus
  2. Add export DBUS_SESSION_BUS_ADDRESS='unix:path='$DBUS_LAUNCHD_SESSION_BUS_SOCKET to .zshrc
  3. Changed the value of <auth><\auth> in /usr/local/opt/dbus/share/dbus-1/session.conf from EXTERNAL to DBUS_COOKIE_SHA1
  4. Run brew services start dbus
  5. Install Zathura
# unlink installed zathura and girara
brew unlink girara
brew unlink zathura

# install HEAD
brew install girara --HEAD
$ brew uninstall zathura-pdf-poppler
$ brew uninstall zathura
$ brew install zathura --HEAD --with-synctex
$ brew install zathura-pdf-poppler
$ mkdir -p $(brew --prefix zathura)/lib/zathura
$ ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib
  1. Reboot

Credits go to @ROBERT-MICHAEL who figured out the dbus part.
@flimofly am I missing something?

That's really work bro.

Repository owner deleted a comment from lutalli Nov 26, 2022
Repository owner deleted a comment from lutalli Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug os-mac MacOS / OSX
Projects
None yet
Development

No branches or pull requests

5 participants