emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
479 stars 53 forks source link

Error with inserting citation in LaTeX file: "No such file or directory tex-site" #798

Closed ashton314 closed 11 months ago

ashton314 commented 11 months ago

Description

When I try to invoke citar-insert-citation from a LaTeX file, I get an error saying Cannot open load file: No such file or directory, tex-site. However, the command works just fine if I'm in an org-mode buffer.

Debugger *Backtrace* buffer ``` Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" "tex-site") require(tex-site) load-with-code-conversion("/Users/ashton/Projects/emacs-debugging/elpaca/buil..." "/Users/ashton/Projects/emacs-debugging/elpaca/buil..." t t) require(tex nil t) byte-code("\300\301!\210\300\302\303\304#\210\300\305!\210\300\306!\210\307\310\311\312\313DD\314\315\316\317\320&\7\210\307\321\311\312\322DD\323\315\301\317\324\325\326&\11\210..." [require citar tex nil t reftex-parse reftex-cite custom-declare-variable citar-latex-cite-commands funcall function #f(compiled-function () #) "Citation commands and their argument specs.\n\nThe a..." :group citar-latex :type (alist :key-type (repeat string) :value-type sexp) citar-latex-prompt-for-cite-style #f(compiled-function () #) "Whether to prompt for a citation command when inse..." (radio (const :tag "Prompt for a command" t) (const :tag "Do not prompt for a command" nil)) :safe always citar-latex-default-cite-command #f(compiled-function () #) "Default command for citations.\n\nMust be in `citar-..." string citar-latex-prompt-for-extra-arguments #f(compiled-function () #) "Whether to prompt for additional arguments when in..." boolean] 10) citar-latex-local-bib-files() citar--major-mode-function(local-bib-files ignore) #(#) citar--bibliography-files(#) #(#) citar--bibliographies() citar--format-candidates() citar-select-refs() byte-code("\302\303!\203\13\0\304 \10D\207\305\306\11\"\207" [current-prefix-arg major-mode citar--get-major-mode-function insert-citation citar-select-refs error "Citation insertion is not supported for %s"] 3) command-execute(citar-insert-citation) ```

Reproducing

Here's an example that should work with Emacs 29.1-rc1 (haven't had time to upgrade from the rc yet) with the --init-directory flag. You will need to update the path in citar-bibliography.

early-init.el

(setq gc-cons-threshold 100000000)
(setq package-enable-at-startup nil)
(setq byte-compile-warnings '(not obsolete))

init.el

;; -*- lexical-binding: t -*-

(defvar elpaca-installer-version 0.5)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
                              :ref nil
                              :files (:defaults (:exclude "extensions"))
                              :build (:not elpaca--activate-package)))
(let* ((repo  (expand-file-name "elpaca/" elpaca-repos-directory))
       (build (expand-file-name "elpaca/" elpaca-builds-directory))
       (order (cdr elpaca-order))
       (default-directory repo))
  (add-to-list 'load-path (if (file-exists-p build) build repo))
  (unless (file-exists-p repo)
    (make-directory repo t)
    (when (< emacs-major-version 28) (require 'subr-x))
    (condition-case-unless-debug err
        (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
                 ((zerop (call-process "git" nil buffer t "clone"
                                       (plist-get order :repo) repo)))
                 ((zerop (call-process "git" nil buffer t "checkout"
                                       (or (plist-get order :ref) "--"))))
                 (emacs (concat invocation-directory invocation-name))
                 ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
                                       "--eval" "(byte-recompile-directory \".\" 0 'force)")))
                 ((require 'elpaca))
                 ((elpaca-generate-autoloads "elpaca" repo)))
            (progn (message "%s" (buffer-string)) (kill-buffer buffer))
          (error "%s" (with-current-buffer buffer (buffer-string))))
      ((error) (warn "%s" err) (delete-directory repo 'recursive))))
  (unless (require 'elpaca-autoloads nil t)
    (require 'elpaca)
    (elpaca-generate-autoloads "elpaca" repo)
    (load "./elpaca-autoloads")))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))

(elpaca elpaca-use-package
  (elpaca-use-package-mode)
  (setq elpaca-use-package-by-default t))

(elpaca-wait)

(use-package vertico
  :config
  (vertico-mode))

(use-package citar
  :bind (("C-c b" . citar-insert-citation))
  :custom
  (citar-bibliography '("~/Research/refs.bib")))    ;; FIXME!!!

(use-package auctex
  :bind (("C-c RET" . latex-close-block)))

Load that up, then open a .tex file, then try to run citar-insert-citation.

Expected behavior

Just insert the darn citation like it used to! :)

Emacs version

GNU Emacs 29.1.50 (build 1, aarch64-apple-darwin22.6.0, NS appkit-2299.70 Version 13.5 (Build 22G74)) of 2023-07-31

bdarcus commented 11 months ago

I don't really use citar with latex-mode; updating my Emacs build to test this.

Any chance this earlier issue sheds any light?

https://github.com/emacs-citar/citar/issues/370

I doubt it, since it seems you are installing AucTeX ...

bdarcus commented 11 months ago

So I can reproduce it, but have no idea what's going on. The backtrace, IUC, shows that AucTeX is trying load that file; not citar. We rely on AucTeX to parse the citations and such.

Any ideas @aikrahguzar?

bdarcus commented 11 months ago

This, from straight, may have some hints?

https://github.com/radian-software/straight.el/issues/240

EDIT: seems you ran into this issue before with Elpaca?

https://github.com/progfolio/elpaca/issues/14

But it's been awhile, so the solution prog provides doesn't work.

ashton314 commented 11 months ago

auctex is such a headache—I forget why I had it installed in the first place. I think I wanted some nice capf functionality, but it's just not worth it. (Wasn't good with auctex to begin with.)

Something funny happened the first time I tried using citar without auctex, so I installed it again. But after removing it from that example file I sent, citar worked like a charm.

Ugh. Auctex, why can't you just be normal?!

ashton314 commented 11 months ago

Oh! New problem! Sorry @bdarcus .

Without Auctex, the popup shows as normal. However, when I select a citation, I get an error that says "Please install AUTeX".

Debugger entered--Lisp error: (error "Please install AUCTeX")
  error("Please install AUCTeX")
  citar-latex--macro-bounds()
  citar-latex-insert-citation(("culpepperFortifyingMacros2012") nil nil)
  citar--major-mode-function(insert-citation ignore ("culpepperFortifyingMacros2012") nil)
  citar-insert-citation(("culpepperFortifyingMacros2012") nil)
  funcall-interactively(citar-insert-citation ("culpepperFortifyingMacros2012") nil)
  command-execute(citar-insert-citation)
bdarcus commented 11 months ago

Yeah, so you'll have to figure out how to install it with elpaca.

Maybe ask a follow-up to that issue?

ashton314 commented 11 months ago

Sorry—I missed a message in this thread. I bet I can figure it out now. I'll let you know if it goes sideways. Thank you so much for your help and the speedy response!

ultronozm commented 10 months ago

Try this:

(use-package latex
  :elpaca  (auctex
            :files ("*.el" "*.info" "dir"
                    "doc" "etc" "images" "latex" "style")
            :pre-build 
            (("./autogen.sh")
             ("./configure" "--with-texmf-dir=$(dirname $(kpsexpand '$TEXMFHOME'))")
             ("make")
             ("make" "install")))
  :demand)