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

Zathura doesn't open when called #2391

Closed
liamd101 opened this issue May 14, 2022 · 30 comments
Closed

Zathura doesn't open when called #2391

liamd101 opened this issue May 14, 2022 · 30 comments
Labels

Comments

@liamd101
Copy link

Description

I am trying to set up Zathura to view pdfs when working with Vimtex, but I cannot get it to work. When I run :VimtexCompile or :VimtexView, nothing seems to happen and I cannot figure out why. I am very new to this, so I apologize if I am missing something obvious.

Steps to reproduce

minimal.vim

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

minimal.tex

\documentclass{minimal}

\begin{document}
Hello world!
\end{document}
  1. vim -u minimal.vim minimal.tex
  2. Compile with \ll or :VimtexCompile
  3. Get VimtexInfo
  4. \lv or :VimtexView

Expected behavior

Zathura to open up with a pdf preview of the document.

Actual behavior

Nothing happens.

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: macOS 12.3.1 (21E258)
  Vim version: VIM 8.2 (1-3455)
  Has clientserver: true
  Servername: undefined (vim started without --servername)

VimTeX project: minimal
  base: minimal.tex
  root: /Users/liamdodds
  tex: /Users/liamdodds/minimal.tex
  main parser: current file verified
  document class: minimal
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: process 5030 run
      output: /var/folders/kc/pj12l0192gg4ljyhsk5y9w1h0000gn/T/v0Fason/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -view=none -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ;
      pid: 5030
  viewer: Zathura
    xwin id: Failed creating new xdo instance.
    cmd_start: zathura  -x "/usr/local/Cellar/macvim/8.2-172_1/MacVim.app/Contents/MacOS/Vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward
  qf method: LaTeX logfile
@liamd101 liamd101 added the bug label May 14, 2022
@lervag
Copy link
Owner

lervag commented May 14, 2022

Did you read :help vimtex-faq-zathura-macos?

@liamd101
Copy link
Author

Yes, I followed those directions when installing initially. I am/was following this guide to set everything up, and I don't think I missed any steps.

@lervag
Copy link
Owner

lervag commented May 14, 2022

Great. Have you tested that Zathura works when you start it from the terminal?

Next, if it works: Can you repeat your initial test steps until \lv. Then do \li to see VimtexInfo. Copy the cmd_start from the viewer and see what happens if you run that from a terminal.

@liamd101
Copy link
Author

When I run it from my terminal, a Zathura black window opens up with the title "org.pwmt.zathura" with text saying "[No name]" in the bottom of the window.

Copying my cmd_start into a terminal outputs

Liams-MBP:~ liamdodds$ zathura  -x "/usr/local/Cellar/macvim/8.2-172_1/MacVim.app/Contents/MacOS/Vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'minimal.tex' 'minimal.pdf'&
[1] 5521
Liams-MBP:~ liamdodds$ error: Could not connect to session bus: Cannot autolaunch D-Bus without X11 $DISPLAY
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1]+  Exit 255                zathura -x "/usr/local/Cellar/macvim/8.2-172_1/MacVim.app/Contents/MacOS/Vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'minimal.tex' 'minimal.pdf'
Liams-MBP:~ liamdodds$ 

@lervag
Copy link
Owner

lervag commented May 14, 2022

So, for some reason, there's a problem with dbus (the man topic of the faq section). I don't use MacOS and can't be of much help. Sorry. There have been several related issues, perhaps you can find some hints in one of them?

@ejmastnak
Copy link
Contributor

Hey @liamd101! Sorry you are having trouble even though you followed the guide's instructions. Working with Linux programs like Zathura on macOS can be very finicky, so I'm not surprised dbus and Zathura are causing problems.

I just tried updating to your version of macOS (12.3.1) and can confirm Zathura is working properly on my machine, which makes me think---at least on principle---we can get it to work for you too.

Can you check the output of brew info zathura, brew info dbus, and brew services info dbus and paste them here? I want to make sure we have the same versions.

Here is what I get on my end (some irrelevant parts omitted):

$ brew info zathura
zegervdv/zathura/zathura: stable 0.4.8, HEAD
https://pwmt.org/projects/zathura/
/usr/local/Cellar/zathura/HEAD-87989da (51 files, 749.1KB) *
  Built from source on 2022-03-14 at 18:38:42 with: --with-synctex
From: https://github.com/zegervdv/homebrew-zathura/blob/HEAD/zathura.rb
==> Dependencies
Required: pkg-config ✔, libmagic ✔, gettext ✔, girara ✔, gnome-icon-theme ✔, glib ✔, desktop-file-utils ✔, intltool ✔, sphinx-doc ✔, meson ✔, gtk-mac-integration ✔
Optional: synctex ✔
==> Options
--with-synctex
        Build with synctex support
--HEAD
        Install HEAD version
$ brew info dbus
dbus: stable 1.14.0 (bottled), HEAD
Message bus system, providing inter-application communication
https://wiki.freedesktop.org/www/Software/dbus
/usr/local/Cellar/dbus/1.14.0 (77 files, 2.5MB) *
  Poured from bottle on 2022-03-14 at 18:17:51
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/dbus.rb
License: AFL-2.1 or GPL-2.0-or-later
==> Dependencies
Build: pkg-config ✔, xmlto ✘
==> Options
--HEAD
        Install HEAD version
$ brew services info dbus
dbus (org.freedesktop.dbus-session)
Running: ✔
Loaded: ✔
Schedulable: ✘

Note that I am no macOS expert---I use Linux on my main machine---so I can't guarantee a solution. But I'll do what I can to help; I definitely don't want to have a tutorial that is misleading users/doesn't work, especially since new VimTeX users might be reading it.

On that note, @lervag, I think I might add a sort of "Caveat: your mileage may vary warning, use at your own risk" warning to the macOS/Zathura section of the guide, since I don't daily-drive macOS, Apple has been known to break things unexpectedly, and there are so many moving parts with getting dbus playing nicely with Zathura and VimTeX on mac. What do you think?

@lervag
Copy link
Owner

lervag commented May 15, 2022

Thanks for pitching int, @ejmastnak! For your question: I agree, but let's wait until we've (hopefully) resolved this issue first. It may bring more useful information on the table that can be relevant for an update to the docs.

@TornaxO7
Copy link
Contributor

TornaxO7 commented May 15, 2022

Interestingly sioyek doesn't work "anymore" for me as well.

let g:vimtex_view_method = 'sioyek'

I have this line in my config. It used to work but it didn't work anymore for some days (or even weeks) now.
zathura is working instead interestingly.

@lervag
Copy link
Owner

lervag commented May 15, 2022

Sorry, @TornaxO7, but now you are being very off topic. Please open a new issue if something is not working as expected, and please, provide the relevant and necessary details when you do.

@TornaxO7
Copy link
Contributor

Sorry, @TornaxO7, but now you are being very off topic.

oh sorry, I thought that this might suit here

@lervag
Copy link
Owner

lervag commented May 15, 2022

I hope I did not come off too aggressive. I just didn't understand how your obvservation was relevant to this thread. The topic is Zathura; MacOS; D-Bus. Why is Sioyek relevant? And why is it relevant that Zathura works for you? (It works for me as well; and last I tried, Sioyek worked for me.)

@liamd101
Copy link
Author

Can you check the output of brew info zathura, brew info dbus, and brew services info dbus and paste them here? I want to make sure we have the same versions.

Here are the outputs:

Liams-MBP:~ liamdodds$ brew info zathura
zegervdv/zathura/zathura: stable 0.4.8, HEAD
https://pwmt.org/projects/zathura/
/usr/local/Cellar/zathura/HEAD-72f3ce1 (51 files, 625.4KB) *
  Built from source on 2022-05-14 at 09:54:09 with: --with-synctex
From: https://github.com/zegervdv/homebrew-zathura/blob/HEAD/zathura.rb
==> Dependencies
Required: pkg-config ✔, libmagic ✔, gettext ✔, girara ✔, gnome-icon-theme ✔, glib ✔, desktop-file-utils ✔, intltool ✔, sphinx-doc ✔, meson ✔, gtk-mac-integration ✔
Optional: synctex ✔
==> Options
--with-synctex
	Build with synctex support
--HEAD
	Install HEAD version
Liams-MBP:~ liamdodds$ brew info dbus
dbus: stable 1.14.0 (bottled), HEAD
Message bus system, providing inter-application communication
https://wiki.freedesktop.org/www/Software/dbus
/usr/local/Cellar/dbus/1.14.0 (77 files, 2.5MB) *
  Poured from bottle on 2022-05-14 at 09:42:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/dbus.rb
License: AFL-2.1 or GPL-2.0-or-later
==> Dependencies
Build: pkg-config ✔, xmlto ✘
==> Options
--HEAD
	Install HEAD version
==> Caveats
To start dbus now and restart at login:
  brew services start dbus
==> Analytics
install: 31,103 (30 days), 130,003 (90 days), 319,854 (365 days)
install-on-request: 975 (30 days), 4,945 (90 days), 10,885 (365 days)
build-error: 5 (30 days)
Liams-MBP:~ liamdodds$ brew services info dbus
dbus (org.freedesktop.dbus-session)
Running: ✘
Loaded: ✔
Schedulable: ✘

The only differences I notices in our two outputs were the "Running" line and the caveat in dbus. Since I was actually given steps/prompt for the caveat, I started with that.

I ran brew services start dbus, and the output was this:

Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501/Users/liamdodds/Library/LaunchAgents/org.freedesktop.dbus-session.plist` exited with 5.

So I ran sudo brew services start dbus, which gave me

Warning: Taking root:admin ownership of some dbus paths:
  /usr/local/Cellar/dbus/1.14.0/bin
  /usr/local/Cellar/dbus/1.14.0/bin/dbus-daemon
  /usr/local/opt/dbus
  /usr/local/opt/dbus/bin
  /usr/local/var/homebrew/linked/dbus
This will require manual removal of these paths using `sudo rm` on
brew upgrade/reinstall/uninstall.
Warning: dbus must be run as non-root to start at user login!
/Library/LaunchDaemons/org.freedesktop.dbus-session.plist: service already bootstrapped
Bootstrap failed: 37: Operation already in progress
Error: Failure while executing; `/bin/launchctl bootstrap system /Library/LaunchDaemons/org.freedesktop.dbus-session.plist` exited with 37.

I am assuming that I should just run sudo rm /usr/local/Cellar/dbus/1.14.0/bin, etc for those, but I don't want to accidentally remove something I shouldn't have.

@ejmastnak
Copy link
Contributor

Here are the outputs:

Great, thanks for checking! So it looks like the dbus service isn't running, which would explain why Zathura was complaining about dbus.

Could you check two more things:

  1. The output of echo $DBUS_SESSION_BUS_ADDRESS (making sure the environment variable DBUS_SESSION_BUS_ADDRESS has been set)
  2. The output of grep "<auth>" /usr/local/opt/dbus/share/dbus-1/session.conf (checking the authentication mechanism set in your dbus session config file)

For reference, here is my echo $DBUS_SESSION_BUS_ADDRESS (yours will probably be slightly different, but we're expecting something in /private/tmp.)

$ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/private/tmp/com.apple.launchd.HGNwmUAuFv/unix_domain_listener

And my authentication method:

$ grep "<auth>" /usr/local/opt/dbus/share/dbus-1/session.conf
  comment out the <auth> element to allow fallback to DBUS_COOKIE_SHA1. -->
  <auth>DBUS_COOKIE_SHA1</auth>

@liamd101
Copy link
Author

echo $DBUS_SESSION_BUS_ADDRESS has no output.

And grep "<auth>" /usr/local/opt/dbus/share/dbus-1/session.conf:

Liams-MBP:~ liamdodds$ grep "<auth>" /usr/local/opt/dbus/share/dbus-1/session.conf
  comment out the <auth> element to allow fallback to DBUS_COOKIE_SHA1. -->
  <auth>DBUS_COOKIE_SHA1</auth>

@ejmastnak
Copy link
Contributor

And grep "" /usr/local/opt/dbus/share/dbus-1/session.conf:

This looks good! Clearly you've followed :help vimtex-faq-zathura-macos, since you're using DBUS_COOKIE_SHA1.

echo $DBUS_SESSION_BUS_ADDRESS has no output.

Interesting, perhaps this is the problem. How are you currently going about setting this environment variable?

Perhaps relevant: are you using zsh or bash (or something else) as your shell?

I'm realizing now that I had only tested the guide on macOS when running bash, in which case I had set export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" in my .bashrc, which I in turn had sourced from my .bash_profile. Let me play around a bit and get back to you.

@m-zheng
Copy link

m-zheng commented May 16, 2022

This link might be helpful.

@ejmastnak
Copy link
Contributor

ejmastnak commented May 16, 2022

@liamd101 After messing around a bit, I can confirm that when the $DBUS_SESSION_BUS_ADDRESS environment variable is not set, I can reproduce your originally posted issue, i.e. :VimtexView does not open Zathura

Running export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" (as suggested in the link posted just now by @m-zheng) either manually or in a shell startup file fixes the problem for me (tested on both Bash and ZSH).

[Edit] What happens if you set export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" manually, then in the same shell session open Vim and trying to reproduce the issue?

@liamd101
Copy link
Author

liamd101 commented May 16, 2022

How are you currently going about setting this environment variable?

Sorry, but I don't fully understand. Like I said before, I'm still very new to all of this. I am currently using bash as my shell, but when I open a terminal it says

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

Manually setting export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" got Zathura to work in the same shell session. However, running vim in a separate session without manually setting it doesn't work, so I guess I set up my .bashrc file incorrectly.

@ejmastnak
Copy link
Contributor

ejmastnak commented May 16, 2022

Manually setting export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" got Zathura to work in the same shell session.

Excellent, I promise we are almost at a solution now.

No worries about being new to the shell stuff. And you're right---there are quite a few concepts to wrap your head around here.

First let me give you a TLDR solution (I hope):

  • Double check you are using Bash by running echo $0 in a terminal---this is a nifty command to print your current shell. I'll assume you are indeed using Bash.

  • If it does not already exist, create the file .bash_profile in your home directory. You can create this file manually, e.g. vim ~/.bash_profile (the ~ character is shorthand for your home directory)

  • Inside the .bash_profile file, write the same command you've been using so far:

    export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET"

    Bash will then run this command automatically for you, and you won't need to type it manually like you did above. Placing this export statement in one of your shell's startup files is what I meant when I was asking about setting environment variables earlier---DBUS_SESSION_BUS_ADDRESS is an environment variable, and, loosely, you are "setting" it with the export statement.
    Save the file and exit Vim.

  • Open a new terminal, run exec bash -l (which ensures Bash will run as a login shell and read the .bash_profile file) and check the output of echo DBUS_SESSION_BUS_ADDRESS, which should no longer be blank.

  • Try reproducing the original issue. Zathura should now open without you having to manually run the export command.

I guess I set up my .bashrc file incorrectly.

Hmm, in principle I don't see why placing export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET" in the ~/.bashrc file in your home directory wouldn't have worked. But let's see what happens when using the ~/.bash_profile file instead.

[Edit] Additions:

Details, details

There are two (not necessarily mutually exclusive) classes of shells:

  • Login vs non-login shells
  • Interactive vs. non-interactive shells

You can customize a shell's behavior with startup files (like you customize Vim with a vimrc file), and a very common use of start up files is to set environment variables, just like we did with DBUS_SESSION_BUS_ADDRESS here.

Things get complicated with choosing the right start-up file for the job. For better or worse, there is a whole zoo of shell start-up files (rc, profile, logout...), which can be placed either in your home directory or in the etc directory, and each class of shell reads a different type of start-up file, and each shell (e.g. Bash, ZSH, etc.) uses a different start-up file. Making sense of all this takes some time, and falls beyond the scope of this thread.

If you want to go down this rabbit hole, I'd start by reading up on the differences between login/non-login and interactive/non-interactive shells and which start-up files each reads. Perhaps the community can recommend some references.

But if you're new, tackling the shell start-up script zoo might be more overwhelming than it is helpful, and it might be more productive to get comfortable with a basic ~/.bash_profile set up first. Many users won't need to understand everything here, and, for better or worse, can get away with just throwing things in their ~/.bash_profile when needed (especially on macOS, where all interactive shells are login shells by default).

Sigh. I hope this more helpful than overwhelming :)

@liamd101
Copy link
Author

That worked! Thanks so much for your help and your guide!

As for the details, they are both helpful and overwhelming haha

@ejmastnak
Copy link
Contributor

ejmastnak commented May 17, 2022

That worked! Thanks so much for your help and your guide!

Great, glad to hear! In that case you can probably close the issue.

And I'll add a few more lines to the guide about making sure the DBUS_SESSION_BUS_ADDRESS environment variable is properly set.

@lervag lervag closed this as completed May 17, 2022
@lervag
Copy link
Owner

lervag commented May 17, 2022

Thanks, @ejmastnak! You could do a PR, or just suggest a change here and I'll add it.

@ejmastnak
Copy link
Contributor

ejmastnak commented May 17, 2022

Thanks, @ejmastnak! You could do a PR, or just suggest a change here and I'll add it.

Aha, I meant I would add a few more lines to the guide on my website. I think :help vimtex-faq-zathura-macos looks good as is, but I suppose it wouldn't hurt to stress the importance of setting DBUS_SESSION_BUS_ADDRESS in step two, e.g.

2. Add this to your `.bashrc` or `.zshrc` file (or similar):
export DBUS_SESSION_BUS_ADDRESS="unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET"
+ The `DBUS_SESSION_BUS_ADDRESS` environment variable must be set for Zathura to work with VimTeX; see [2] for details.

[0]: https://github.com/lervag/vimtex/issues/1737#issuecomment-759953886
[1]: https://brew.sh
+ [2]: https://github.com/lervag/vimtex/issues/2391

Edit: or perhaps link directly to #2391 (comment) or similar, to avoid the irrelevant (in this context) material in the first few comments.

@lervag
Copy link
Owner

lervag commented May 17, 2022

Thanks!

lervag added a commit that referenced this issue May 17, 2022
@TornaxO7
Copy link
Contributor

Sorry for the late reply @lervag !

I hope I did not come off too aggressive.

Don't worry, nothing happened :)

I just didn't understand how your obvservation was relevant to this thread. The topic is Zathura; MacOS; D-Bus. Why is Sioyek relevant? And why is it relevant that Zathura works for you?

I can understand your points. I thought that my current issue with sioyek might
be related with zathura, that's why I wrote this message.

@lervag
Copy link
Owner

lervag commented May 17, 2022

Great, and no problem. I'm happy that you chose to act with those good intentions, and I hope I did not scare you from doing the same in the future. :)

@TornaxO7
Copy link
Contributor

TornaxO7 commented May 17, 2022

and I hope I did not scare you from doing the same in the future. :)

Hihi, don't worry about that c(^-^)c

@ucasyfp
Copy link

ucasyfp commented Jun 15, 2022

I have a very similar problem with OP, but instructions above cannot fix mine. I followed vimtex-help to set up zathura and dbus. I have added export statement to bashrc,bash_profile,zshrc,zsh_profile. Echo in terminal shows that environment variable have been set up correctly, and output for grep "<auth>" /usr/local/opt/dbus/share/dbus-1/session.conf is also correct, still dbus is not running.

And the error message for brew services start dbus and sudo brew services start dbus are just the same as OP's.

When I run cmd_start in terminal, it returns

zathura  -x "/usr/local/Cellar/neovim/0.7.0/bin/nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 13:1:'/Users/yfp/tex documents/笔记/2022-06-15/note.tex' 'note.pdf'&

[1] 8675
 ~  error: Could not connect to session bus: Could not connect: Permission denied2:21 PM
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1]  + 8675 exit 255   zathura -x  --synctex-forward  'note.pdf'

I use neovim and zsh, with iterm2. Do you guys have any clues?

@ejmastnak
Copy link
Contributor

Hey @ucasyfp, I'm not immediately sure how to solve your issue. It would probably be a good idea to open a separate issue with your system information and complete steps to reproduce your issue.

I would start by uninstalling and re-installing the relevant software: run brew unlink and then brew uninstall for each of the following Homebrew packages:

  • dbus,
  • zathura-pdf-poppler (or zathura-pdf-mupdf if you use that instead of zathura-pdf-poppler),
  • zathura
  • and girara.

Then, once you have a clean slate, try exactly repeating the steps in :help vimtex-faq-zathura-macos.

@lervag
Copy link
Owner

lervag commented Jun 16, 2022

@ucasyfp Unless the tips from @ejmastnak works, please open a new issue with a full description.

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

6 participants