Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ashton314 opened this issue Aug 1, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@ashton314
Copy link

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 () #<bytecode 0x19800016fe914>) "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 () #<bytecode 0x19800016fe5d4>) "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 () #<bytecode 0x1980009fd5dd4>) "Default command for citations.\n\nMust be in `citar-..." string citar-latex-prompt-for-extra-arguments #f(compiled-function () #<bytecode 0x19800016fe5d4>) "Whether to prompt for additional arguments when in..." boolean] 10)
  citar-latex-local-bib-files()
  citar--major-mode-function(local-bib-files ignore)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_37>(#<buffer paper.tex>)
  citar--bibliography-files(#<buffer paper.tex>)
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_38>(#<buffer paper.tex>)
  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

@ashton314 ashton314 added the bug Something isn't working label Aug 1, 2023
@bdarcus
Copy link
Contributor

bdarcus commented Aug 1, 2023

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

Any chance this earlier issue sheds any light?

#370

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

@bdarcus
Copy link
Contributor

bdarcus commented Aug 1, 2023

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
Copy link
Contributor

bdarcus commented Aug 1, 2023

This, from straight, may have some hints?

radian-software/straight.el#240

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

progfolio/elpaca#14

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

@ashton314
Copy link
Author

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?!

@bdarcus bdarcus closed this as completed Aug 1, 2023
@ashton314
Copy link
Author

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
Copy link
Contributor

bdarcus commented Aug 1, 2023

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

Maybe ask a follow-up to that issue?

@ashton314
Copy link
Author

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
Copy link

ultronozm commented Aug 15, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants