10

Aim

I would like to get PDF Tools installed on my GUI Emacs on MacOSX (version 25.0.50 installed via Homebrew on MacOSX 10.10.2) because the README says it's possible.

Setup

I installed poppler and exported the PKG_CONFIG_PATH variable to my shell as advised by the README.

I then installed PDF Tools via MELPA and it installed a directory in my .emacs.d/elpa directory named ~/.emacs.d/elpa/pdf-tools-20150620.1632

Problem

When I ran the pdf-tools-install command I get the following errors about not being able to find the correct directory:

Need to build the server, do it now ? (y or n) y

pdf-tools--melpa-build-server: No such directory: /Users/m/.emacs.d/elpa/pdf-tools-20150613.414/build

What I've tried

  • I have tried re-installing the package with package-reinstall

  • I have searched for specific answers on EmacsWiki, this site, reddit.

2
  • 1
    For a period of time melpa hosted a broken package and that's most likely causing this problem. You should update it.
    – politza
    Commented Jun 21, 2015 at 17:30
  • 1
    Your install directory in MELPA is pdf-tools-20150620.1632, but your error shows another directory, pdf-tools-20150613.414. Something's wrong. Reinstall the packages to reset any older versions that may be causing this. @politza's advice may fix this.
    – Emacs User
    Commented Jun 21, 2015 at 22:37

9 Answers 9

14

For me, as of April 13, 2017, a reliable way to install pdf-tools on OS X (Mavericks/Sierra) is to use the following pdf-tools config and directions (in the comments):

;;; Install epdfinfo via 'brew install pdf-tools --HEAD' and then install the
;;; pdf-tools elisp via the use-package below. To upgrade the epdfinfo
;;; server, just do 'brew upgrade pdf-tools' prior to upgrading to newest
;;; pdf-tools package using Emacs package system. If things get messed
;;; up, just do 'brew uninstall pdf-tools', wipe out the elpa
;;; pdf-tools package and reinstall both as at the start.

(use-package pdf-tools
      :ensure t
      :config
      (custom-set-variables
        '(pdf-tools-handle-upgrades nil)) ; Use brew upgrade pdf-tools instead.
     (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo"))
     (pdf-tools-install)

Of course, you don't have to use use-package. You can just require pdf-tools after installing it via Emacs package system and then require it, but you do still have to define the path to epdfinfo as in the code above.

5
  • 1
    Although this installation method worked for me (+1), just an FYI: I cannot seem to use (pdf-tools-handle-upgrades nil) - I get function void an error. I don't use use-package, so have tried altering the order of things in my .emacs., without success. Not a major issue, as you provide an answer for upgrading too :) Installing from homebrew required brew install homebrew/emacs/pdf-tools. Skimming through the terminal output, I think this is because Mavericks is no longer supported by either Homebrew or Apple.
    – n1k31t4
    Commented Oct 3, 2016 at 11:15
  • This snippet failed for me when attempting to download specific dated versions of tablist and pdf-tools. It worked fine with :pin melpa-stable. Thanks!
    – Dave
    Commented Aug 13, 2018 at 9:39
  • 8
    The Homebrew formula for pdf-tools is no longer part of homebrew-core; it's been migrated to dunn/emacs, so you first need to run brew tap dunn/emacs.
    – Adam Liter
    Commented Aug 18, 2018 at 2:05
  • 4
    use brew install pdf-tools --HEAD in case you get compiling error with brew install pdf-tools
    – reFORtEM
    Commented Nov 3, 2018 at 10:58
  • As of January 2023, simply following the advice posted by @Joe worked out for me in my MacOS 13.1 (22C65) (venture) with M1 hardware. Commented Jan 25, 2023 at 16:28
4

It worked!

I am not 100% sure on the specifics as to what made it work. As commenters correctly point out, there was an issue with the packages/directories that were installed/compiled but it worked the next time I ran pdf-tools-install

Things I tried/did

  • I started/re-started my emacs --daemon server (ie turned on/off my computer)
  • re-installed the pdf-tools package again (I had tried this, yes)
  • Installed CLISP via homebrew (I have a suspicion this may have helped the script find the right directories because when I was running it via pdf-tools-install it was asking for a directory where autogen.sh was and I was pointing it to the elpa/pdf-tools directory and had tried /usr/local/Cask/... directories where homebrew installed Emacs. Maybe this helped it find the right ones?

Anyways, super happy now as can have my PDF's inside Emacs and as an extra bonus it seems to render eww buffers much better too.

Best of luck to other OSX users getting it up and working. Please post if you pinpoint what helped you get it set up.

Thank you @politza!

enter image description here

2
  • 2
    You certainly do not need CLIPS for pdf-tools to work.
    – user2005
    Commented Oct 13, 2015 at 11:22
  • No maybe not, but CLISP helped me and @Dexter Morgan :)
    – m__
    Commented Oct 17, 2015 at 4:43
3

I have poppler and automake installed using homebrew, however pdf-tools-install failed with: no such program autoreconf. I retried pdf-tools-install from tty/terminal Emacs and everything built correctly. I think some environment settings weren't being picked up in GUI-based Emacs.

0

[I don't have enough rep to comment]

Installing CLISP and poppler helped me - It didn't work at all before that.

After having these installed (and restarting my machine), I managed to get install successfully (hooray!) - however only with a mixture of terminal and emacs.

According to the instructions You can complete both stages (the compilation and the installation) either via the terminal or within Emacs...

I had to specifically do the compilation in the terminal (to create the pdf-tools-${VERSION}.tar file), but the installation then had to be done in Emacs i.e. using M-x package-install-file RET pdf-tools-${VERSION}.tar RET.

I do not know how the two processes differ, but maybe this helps somebody else out.

0

I just want to shortly explain how I did it while using use-package and how it should probably work for anybody. On a terminal:

brew install poppler automake

Then in emacs run the following:

; This goes into your emacs config file
(use-package pdf-tools
  :ensure t
  :config
  (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo"))

;; this only has to be executed for the installation and can be removed/commented afterwards
;; I recommend commenting it out so that it can be found easily when reinstalling
(setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig")
(pdf-tools-install)

As already said, this will fail, but you should get a buffer called *compilation* which looks like this:

-*- mode: compilation; default-directory: "~/.emacs.d/elpa/pdf-tools-20191228.1005/build/server/" -*-
Comint started at Sat Jan  4 21:51:49

/PATH/TO/elpa/pdf-tools-20191228.1005/build/server/autobuild -i /usr/local/bin/
Failed to recognize this system, trying to continue.
---------------------------
 Configuring and compiling 
---------------------------
No such program: autoreconf

Comint exited abnormally with code 1 at Sat Jan  4 21:51:49

(the reason for the error seems to be that "/usr/local/bin" is not in the $PATH variable and it's kinda hard to add it, as subprocesses of emacs use the default $PATH which usually misses this directory)

Now all you have to do is copy the following line from the buffer and run it in a terminal again (where /usr/local/bin is in the $PATH):

/PATH/TO/elpa/pdf-tools-20191228.1005/build/server/autobuild -i /usr/local/bin/
0

This answer assumes that the user has a Macports installation with the poppler port/package installed. [I have a small fleet of older machines still running OSX 10.6.8 (Snow Leopard), and that is the system that I used to install pdf-tools. My poppler version is 0.42.0_0. See the pdf-tools README.md for additional requirements -- they were probably already installed via Macports.]

  • Download and extract pdf-tools-master.zip, or clone the repository to the local machine.

  • I used eshell within Emacs and ran the following configuration:

    (progn (setenv "PATH" "/usr/bin:/bin:/usr/sbin:/sbin:/path/to/macports/bin") (setenv "CPPFLAGS" "-I/path/to/macports/include") (setenv "LDFLAGS" "-L/path/to/macports/lib") (setenv "CFLAGS" "-Wall -O0 -g3"))

You can, of course, use the terminal and configure the relevant settings instead of using eshell.

  • cd over to the repository directory ../pdf-tools-master/server

  • ./autogen.sh

  • ./configure --prefix=/path/to/macports or elsewhere if so desired.

  • After running the configure in the step above, I encountered an error:

    ./configure: line 4745: syntax error near unexpected token 'png,' ./configure: line 4745: 'PKG_CHECK_MODULES(png, libpng)'

  • Googled and found: https://github.com/politza/pdf-tools/issues/142

  • Recommended workaround is to run autoreconf:

  • /path/to/macports/bin/autoreconf

  • Then run configure again -- this time it worked as expected.

  • ./configure --prefix=/path/to/macports or elsewhere if so desired.

  • make

  • make install

  • Verify you have the newly installed epdfinfo at the set prefix location; e.g.,

    /path/to/macports/bin/epdfinfo

  • Copy the lisp files over to the load-path of Emacs -- the lisp files are in the repository at ../pdf-tools-master/lisp

  • If the PATH to epdfinfo is not at a location where Emacs can locate it, then adjust that ... beyond the scope of this answer. Or, you can set the absolute path by configuring the variable pdf-info-epdfinfo-program.

  • I also configured the exact location for convert by setting the variable pdf-util-convert-program; or, you can adjust the PATH so Emacs knows where to look for the executable.

  • In Emacs, evaluate (require 'pdf-tools)

  • Try it out by enabling pdf-view-mode in a PDF file buffer.

0

When some packages are updated it is necessary to update also their dependencies or prerequisite files. In this case, the server needs some requirements (for more information go to https://github.com/politza/pdf-tools, prerequisite section). Therefore, I just follow the instructions there:

  1. Install or Re-install poppler which you can get with homebrew via:
    $ brew install poppler automake
  1. Find some libraries for pkg-config by setting PKG_CONFIG_PATH:
$ export PKG_CONFIG_PATH=/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig

and the try to run again emacs or spacemacs.

0

Even with those many discussions, I still struggled a lot with the installation of pdf-tools as of 14/08/2020.

I am using Emacs 27.1 (homebrew cask installation). My masOS is Catalina Version 10.15.5.

Here is what I did:

  1. I successfully followed the instructions here to install pdf-tools from melpa in Emacs. However, I was not able to open pdf in a proper format. It was always in binary format. Then I downloaded the installation file here. After all sorts of trials and errors, I failed to compile it. I raised a question here.

  2. I tried the techniques I found here including the installation of CLISP. I also tried to modify the Makefile and other silly things.

  3. I tried to install all of the dependencies by referring to the cask file in the cloned pdf-tools files inside Emacs. I was still not able to run pdf-tools.

  4. I tried pdf-tools-install in Emacs. It seemed I went through the process though I still cannot run pdf-tools. Accidentally, I did not give permission to the following prompt after issuing pdf-tools-install. The prompt was something like 'you need to (re)compile pdf-tools' (cannot recall clearly). The installation magically went ahead and eventually finished. I can use pdf-tools afterwards.

My experience with the installation is totally by luck. I am happy with the result though it will be better if I can understand why.

However, each time I open emacs now, I still need to reactivate pdf-tools by issuing the command pdf-tools-install. I can bear with it for now.

0

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 :-)

  1. Download and install XQuartz to get X11 in your Mac (this might be unnecessary, but it helped me).

  2. In case you haven't already, install other dependencies through homebrew:

      brew install poppler automake pkg-config
    
  3. Through M-x list-packages, install pdf-tools.

  4. In your init.el file, set the PKG_CONFIG_PATH using setenv:

      (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 and poppler.

  5. Like Joe, I did all this through the use-package configuration macro that helps organize the init.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)))
    
  6. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.