8

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.

  • 1
    For a period of time melpa hosted a broken package and that's most likely causing this problem. You should update it. – politza Jun 21 '15 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 Jun 21 '15 at 22:37
13

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' 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.

| improve this answer | |
  • 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 Oct 3 '16 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 Aug 13 '18 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 Aug 18 '18 at 2:05
  • 4
    use brew install pdf-tools --HEAD in case you get compiling error with brew install pdf-tools – William Nov 3 '18 at 10:58
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

| improve this answer | |
  • 2
    You certainly do not need CLIPS for pdf-tools to work. – rekado Oct 13 '15 at 11:22
  • No maybe not, but CLISP helped me and @Dexter Morgan :) – m__ Oct 17 '15 at 4:43
1

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.

| improve this answer | |
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.

| improve this answer | |
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/
| improve this answer | |
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.

| improve this answer | |
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.

| improve this answer | |
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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