I'm pasting here an answer that I posted somewhere else (refer to that post, which unlike this one, I update regularly), because for a long while I relied on Joe's answer to get pdf-tools
to work on my Mac. I don't exactly know why, everything stopped working a couple of months ago. After a lot of research, trial and error, I got to this.
I believe that the trick that really got everything running was setting the PKG_CONFIG_PATH
to everything that mattered inside the init.el
file (and downloading XQuartz
to get a X11 environment, with the only purpose of having renderproto
in the system; it may have been available in some other easier way, but it was only like this that I managed to do it).
Here are all the key steps involved in getting pdf-tools
back to work in my MacOS Monterey 12.5 running Emacs 28.1 :-)
Download and install XQuartz to get X11 in your Mac (this might be unnecessary, but it helped me).
In case you haven't already, install other dependencies through homebrew:
brew install poppler automake pkg-config
Through
M-x list-packages
, installpdf-tools
.In your
init.el
file, set thePKG_CONFIG_PATH
usingsetenv
:(setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.12/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig:/usr/local/Cellar/poppler/22.06.0_1/lib/pkgconfig:/opt/x11/share/pkgconfig")
Of course, you will have to use your own version numbers and update them every time you upgrade
zlib
andpoppler
.Like Joe, I did all this through the
use-package
configuration macro that helps organize theinit.el
file:(use-package pdf-tools :ensure t :config (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.12/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig:/usr/local/Cellar/poppler/22.06.0_1/lib/pkgconfig:/opt/x11/share/pkgconfig") (pdf-tools-install) (custom-set-variables '(pdf-tools-handle-upgrades t)))
Close and reopen the Emacs.app and, type
y
when prompted to "(re)build the epdfinfo program".
That's all it should take to get pdf-tools
to work. It did it for me, anyway.