I have Emacs 30.2 installed on MacBook Pro (Mac Monterey Version 12.7.6). I cannot make pdf-tools to work. Please see my .emacs file:
**** .emacs file ****************
;; Initialize package sources
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;;; auctex configuration
(use-package auctex
:ensure t
:config
(setq TeX-auto-save t ; Save before compiling
TeX-parse-self t ; Parse file for macros/environments
TeX-PDF-mode t ; Use PDF mode by default
TeX-source-correlate-mode t ; Enable SyncTeX support
TeX-source-correlate-start-server t ; Start SyncTeX server
LaTeX-item-indent 0 ; No indentation for list items
TeX-electric-math t ; Electric math mode
TeX-view-program-selection '((output-pdf "PDF Tools")) ; Use PDF Tools for viewing
TeX-view-program-list '(("PDF Tools" "pdf-tools-view-pdf %o"))))
;;; pdf-tools configuration
(use-package pdf-tools
:ensure t
:config
(pdf-tools-install)
(setq pdf-view-display-size 'fit-width) ; Adjust as needed
(add-hook 'pdf-view-mode-hook 'pdf-tools-enable-minor-modes))
;;; completions and matching
(electric-pair-mode t)
(add-hook 'LaTeX-mode-hook 'LaTeX-electric-env-mode) ; Auto-complete environments
(add-hook 'LaTeX-mode-hook 'LaTeX-electric-left-right-mode) ; Auto-complete brackets
;;; custom set variables
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(LaTeX-command "latex -synctex=1")
'(LaTeX-default-author "Partha Pratim Ghosh")
'(LaTeX-electric-left-right-brace t)
'(TeX-command-list
'(("TeX"
"%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t"
TeX-run-TeX nil (plain-tex-mode texinfo-mode ams-tex-mode) :help
"Run plain TeX")
("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil
(latex-mode doctex-mode) :help "Run LaTeX")
("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile
nil (texinfo-mode) :help "Run Makeinfo with Info output")
("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t"
TeX-run-compile nil (texinfo-mode) :help
"Run Makeinfo with HTML output")
("AmSTeX"
"amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t"
TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
("ConTeXt"
"%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
TeX-run-TeX nil (context-mode) :help
"Run ConTeXt until completion")
("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil
(plain-tex-mode latex-mode doctex-mode context-mode texinfo-mode
ams-tex-mode)
:help "Run BibTeX")
("Biber" "biber %(output-dir) %s" TeX-run-Biber nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run Biber")
("Texindex" "texindex %s.??" TeX-run-command nil (texinfo-mode)
:help "Run Texindex")
("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil
(texinfo-mode) :help "Run Texi2dvi or Texi2pdf")
("Print" "%p" TeX-run-command t t :help "Print the file")
("Queue" "%q" TeX-run-background nil t :help
"View the printer queue" :visible TeX-queue-command)
("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Generate PostScript file")
("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert DVI file to PostScript")
("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert DVI file to PDF with dvipdfmx")
("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Convert PostScript file to PDF")
("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run makeglossaries to create glossary file")
("Index" "makeindex %(O?idx)" TeX-run-index nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run makeindex to create index file")
("upMendex" "upmendex %(O?idx)" TeX-run-index t
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run upmendex to create index file")
("Xindy" "texindy %s" TeX-run-command nil
(plain-tex-mode latex-mode doctex-mode texinfo-mode ams-tex-mode)
:help "Run xindy to create index file")
("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help
"Check LaTeX file for correctness")
("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode) :help
"Check LaTeX file for common mistakes")
("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t
:help "Spell-check the document")
("Clean" "TeX-clean" TeX-run-function nil t :help
"Delete generated intermediate files")
("Clean All" "(TeX-clean t)" TeX-run-function nil t :help
"Delete generated intermediate and output files")
("Other" "" TeX-run-command t t :help "Run an arbitrary command")))
'(TeX-date-format "%d%m%Y")
'(TeX-refuse-unmatched-dollar t)
'(bibtex-file-path
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/")
'(bibtex-files '(bibtex-file-path))
'(cua-mode t)
'(current-language-environment "Bengali")
'(desktop-save-mode 1)
'(doc-view-continuous t)
'(ignored-local-variable-values '((TeX-master . TeX-master:)))
'(initial-buffer-choice
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/symbols.sty")
'(ns-right-alternate-modifier 'none)
'(org-agenda-files '("~/Documents/org/reviews.org"))
'(org-latex-pdf-process '("pdflatex -nonstopmode -synctex=1 %f"))
'(package-archives
'(("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")))
'(package-selected-packages
'(async auctex auto-complete-auctex elpy haskell-mode magit-section
org org-notebook org-noter org-noter-pdftools org-pdftools
org-ref pdf-tools pdf-view-pagemark pdfgrep scheme-complete
use-package))
'(pdf-tools-handle-upgrades nil)
'(reftex-cite-format 'biblatex)
'(reftex-default-bibliography
'("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-algebra.bib"
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-category.bib"
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-frames.bib"
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-self.bib"
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-topology.bib"
"~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/tex/essentials/bib-websites.bib"))
'(reftex-plug-into-AUCTeX t)
'(reftex-section-prefixes
'((0 . "part:") (1 . "cha:") (2 . "sec:") (3 . "ssec:") (4 . "sssec:")
(5 . "para:")))
'(safe-local-variable-values '((TeX-master . t)))
'(save-place-mode t)
'(scheme-program-name
"usr/local/Cellar/mit-scheme/12.1_1/bin/mit-scheme-svm1-64le-12.1")
'(tex-bibtex-command "biber"))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "White" :foreground "Black" :inverse-video nil :box nil :strike-through nil :extend nil :overline nil :underline nil :slant normal :weight normal :height 140 :width normal :foundry "nil" :family "Menlo")))))
Whenever I press C-c C-c to view the .pdf file it returns
Wrong type argument: stringp, nil.
I have no clue what is wrong and what does this error mean.
Any solution to mend this issue would be highly appreciated.
Edit on 23-10-2025:
--- BackTrace entry: -----
Debugger entered--Lisp error: (void-function LaTeX-electric-left-right-mode)
LaTeX-electric-left-right-mode()
run-hooks(change-major-mode-after-body-hook text-mode-hook TeX-mode-hook LaTeX-mode-hook)
apply(run-hooks change-major-mode-after-body-hook (text-mode-hook TeX-mode-hook LaTeX-mode-hook))
run-mode-hooks(LaTeX-mode-hook)
LaTeX-mode()
set-auto-mode-0(latex-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(#<buffer test.tex> "~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/test.tex" nil nil "~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/test.tex" (35129571 16777220))
find-file-noselect("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/test.tex" nil nil t)
find-file("~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/test.tex" t)
funcall-interactively(find-file "~/Library/Mobile Documents/com~apple~CloudDocs/Documents/Documents - Galois/test.tex" t)
call-interactively(find-file nil nil)
command-execute(find-file)
------ end of BackTrace ------
--- Messages buffer: ------
Type ‘C-c C-l’ to display results of compilation.
LaTeX: successfully formatted {1} page
TeX-command-expand: Wrong type argument: stringp, nil
C-c C-c runs the command TeX-command-master
--- end of Messages buffer
The last line came from C-h c C-c C-c.
Just before the last line is recorded the result from hitting C-c C-c.
Edit 2, 23-10-2025:22:43
This is following the suggestions from @phils and @NickD.
I erased the previous Backtrace.
After compiling a test.tex file with LaTeX, now I enabled M-x toggle-debug-on-error and pressed C-c C-c for pdf viewing. The following was obtained.
--- BackTrace message ----
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("\\(?: \"\\\\\\|\"\\|%\\(?:(\\(?:\\(?:O\\?\\(?:aux\\|idx\\|pdf\\)\\|PDF\\(?:out\\)?\\|cntxcom\\|d-dir\\|ex\\(?:\\(?:ec\\|tra\\)opts\\)\\|file-line-error\\|latex\\(?:mk-out\\)?\\|mode\\|o\\(?:-dir\\|\\?\\|utp\\(?:age\\|ut-dir\\)\\)\\|s-filename-only\\|t\\(?:-filename-only\\|ex\\)\\))\\)\\|[cd]S\\|[%'STV`abdfl-t]\\)\\)" nil nil)
TeX-command-expand(nil)
TeX-command("View" TeX-master-file nil)
TeX-command-master(nil)
funcall-interactively(TeX-command-master nil)
call-interactively(TeX-command-master nil nil)
command-execute(TeX-command-master)
--------- end of BackTrace ------
Please accept my thanks for your help; please suggest the way forward.
With my regards and all the very best wishes,
Partha
debug-on-errorand try to do the same thing: you should now get a backtrace, which you should cut and paste into your question. You should also describe where exactly you are doing thatC-c C-cand maybe also what it is bound to in the context where you are using it: doC-h c C-c C-cto find that out. Please add all this information to your question.*.texfile -- seemingly nothing to do with the original question. One problem per question, please. A cursory search forLaTeX-electric-left-right-modesuggests it's part of the auctex package, though. If that's not working, I suggest you reinstall it.TeX-command-expand: Wrong type argument: stringp, nil. You can useM-x toggle-debug-on-errorto enable that setting immediately before usingC-c C-cto trigger the error, which should get the relevant backtrace. Typeqin the backtrace buffer first to dismiss a pre-existing debugger session, if there's already a backtrace -- Emacs can only have a single debugger session at a time. See also gnu.org/software/emacs/manual/html_node/elisp/…C-c C-c: when you press a key sequence in Emacs, it can do different things in different contexts, so you have to specify the context precisely (both in order for us to understand what you are doing and also for things likeC-h c C-c C-cto tell you what the key sequence is bound to in that context). To provide the context, please provide a step-by-step description of what you did exactly. And try to follow @phils's direction wrt to the backtrace.LaTeX-electric-left-right-bracewhich is a custom option.git grepdoesn't find anything about the functionsLaTeX-electric-left-right-modeandLaTeX-electric-env-mode, so reinstalling AUCTeX would not help, I'm afraid. This question was also asked here, FWIW.