emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jun Inoue <jun.lambda@gmail.com>
To: Yaroslav Drachov <drachov.yaroslav@gmail.com>
Cc: Ihor Radchenko <yantar92@posteo.net>,
	Karthik Chikmagalur <karthikchikmagalur@gmail.com>,
	 orgmode@tec.tecosaur.net, emacs-orgmode@gnu.org
Subject: Re: [Pre-PATCH] Overhaul of the LaTeX preview system
Date: Wed, 4 Sep 2024 08:04:55 +0900	[thread overview]
Message-ID: <CA+ZA8QxpfyHAXivuqtQDFuAY4WWikwDmpTib2-hyryoPWwt=tw@mail.gmail.com> (raw)
In-Reply-To: <871q20ag88.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5048 bytes --]

Yaroslav, I had a similar issue.  The problem there was that the relative
path
../../../../var/folders/3m/9xzpnkks773bfdwzqlvr421r0000gn/T/org-tex-BYOo4y-000000001.svg
was being expanded in the wrong directory.  Can you see if the problem
reproduces with the attached patch?  (You could also just find the string
"{?svgfile}" in (alist-get 'dvisvgm org-latex-preview-process-alist) and
replace it with "{?svgpath}".


Here's a copy of the email I sent to this list regarding the issue.  It
seems to have fallen through the cracks, so it would be great if someone
could have a look, independently of Yaroslav's issue if it turns out to be
different.

Recently, the previews stopped working after a system update.

* Symptom
On macOS with dvisvgm 3.2+, org-latex-preview can't typeset LaTeX fragments
at all in a lot of files.  It gives an error like the following:

error in process filter: Opening input file: No such file or directory,
/var/var/folders/8g/k689fc1j3gg2ny7xrzqchjsm0000gn/T/org-tex-ZqKlQw-000000001.svg
[2 times]

** Steps to Reproduce
Put dvisvgm 3.2+ on your path and create a .org file anywhere outside
temporary-file-directory that is shallower than (i.e. has fewer slashes
than) temporary-file-directory.  Try to preview any LaTeX fragment in that
file.

This should theoretically reproduce on non-macOS, but macOS has an
especially deep temporary-file-directory that looks like
/var/folders/8g/k689fc1j3gg2ny7xrzqchjsm0000g, making it easier to
reproduce.  If temporary-file-directory is /tmp on your system, I think you
have to make the .org file in the root directory or change
temporary-file-directory to a deeper directory (haven't tried).

* Cause
This is because org-latex-preview:
1. Runs dvisvgm in the same directory as the .org file, and
2. Tells dvisvgm to report the output SVG file names as relative paths
using ?svgfile, but
3. Then expands those file names under temporary-file-directory in
org-latex-preview--dvisvgm-filter.

So dvisvgm relativizes in one path, then org-latex-preview expands in
another.

For instance, if I try to typeset fragments in /Users/jun/org/test/test.org,
then dvisvgm reports:

output written to:
../../../../var/folders/8g/k689fc1j3gg2ny7xrzqchjsm0000gn/T/org-tex-CWRtgi-000000001.svg

where /var/folders/8g... is the absolute path of the output file.  This is
expanded under temporary-file-directory, which is
/var/folders/8g/k689fc1j3gg2ny7xrzqchjsm0000gn/T, leading org-latex-preview
to busy-wait for files to arrive in
/var/var/folders/8g/k689fc1j3gg2ny7xrzqchjsm0000gn/T.

I think this is hard to reproduce on most non-macOS systems where the
temporary-file-directory is shallow.  ?svgfile contains as many ../ as
there are slashes in the directory hosting the .org file, and expanding
that relative to (say) /tmp will effectively remove all those ../, making
it expand to the correct absolute path by accident.

* Fix
Use ?svgpath instead of ?svgfile.  Here's a patch that applies to commit
9584a76a843e2e8122799e5653bb9120fe568f64 of [[
https://git.tecosaur.net/tec/org-mode.git]].

modified   lisp/org-latex-preview.el
@@ -200,7 +200,7 @@ Place-holders only used by `:image-converter':
                  (list
                   (concat "dvisvgm --page=1- --optimize --clipjoin
--relative --no-fonts"
                           (if (>=
org-latex-preview--dvisvgm3-minor-version 2)
-                              " -v3 --message='processing page {?pageno}:
output written to {?svgfile}'" "")
+                              " -v3 --message='processing page {?pageno}:
output written to {?svgpath}'" "")
                           " --bbox=preview -o %B-%%9p.svg %f"))))))

 (defcustom org-latex-preview-compiler-command-map
@@ -2792,7 +2792,7 @@ EXTENDED-INFO, and displayed in the buffer."
         (when (save-excursion
                 (re-search-forward "output written to \\(.*.svg\\)$" end
t))
           (setq fragment-info (nth (1- page) fragments))
-          (plist-put fragment-info :path (expand-file-name (match-string
1) temporary-file-directory))
+          (plist-put fragment-info :path (match-string 1))
           (when (save-excursion
                   (re-search-forward "^  page is empty" end t))
             (unless (plist-get fragment-info :error)

** Environment
GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, Carbon Version 165
AppKit 2113.6) of 2023-08-09 (Brew tap railwaycat emacs-mac)

dvisvgm 3.2.2

On Wed, Sep 4, 2024 at 12:51 AM Karthik Chikmagalur <
karthikchikmagalur@gmail.com> wrote:

> >> Sorry for delay.
> >>
> >> 1. pdflatex
> >> 2. processing page 1: output written to
> ../../../../var/folders/3m/9xzpnkks773bfdwzqlvr421r0000gn/T/org-tex-BYOo4y-000000001.svg
> >> 3. nil
> >
> > Karthik, any thoughts?
> >
>
> It will be useful to know if that svg exists at that path.  I've had
> reports from other Mac users complaining about dvisvgm reporting the wrong
> path.
>
> Karthik
>
>

-- 
Jun Inoue

[-- Attachment #2: Type: text/html, Size: 6519 bytes --]

  reply	other threads:[~2024-09-03 23:06 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 19:26 [Pre-PATCH] Overhaul of the LaTeX preview system Yaroslav Drachov
2024-04-18 20:04 ` Karthik Chikmagalur
2024-04-18 20:13   ` Yaroslav Drachov
2024-06-23 10:53     ` Ihor Radchenko
2024-06-23 11:00       ` Yaroslav Drachov
2024-06-26 19:05         ` Karthik Chikmagalur
2024-07-02 10:38           ` Yaroslav Drachov
2024-09-03 14:30             ` Ihor Radchenko
2024-09-03 15:50               ` Karthik Chikmagalur
2024-09-03 23:04                 ` Jun Inoue [this message]
2024-09-04  0:18                   ` Karthik Chikmagalur
2024-09-04  0:44                     ` Jun Inoue
  -- strict thread matches above, loose matches on Subject: below --
2024-04-18 21:49 Корякин Артём
2024-04-17 20:11 Корякин Артём
2024-04-18  3:11 ` Karthik Chikmagalur
2024-04-18 20:47   ` Корякин Артём
2024-04-18 15:14 ` Max Nikulin
     [not found]   ` <86edb2ft89.fsf@gmail.com>
2024-04-19  2:23     ` Max Nikulin
2024-04-19  6:53       ` Корякин Артём
2023-08-07  8:12 WANG Yicheng
2023-08-08  8:30 ` Ihor Radchenko
2023-06-04 23:29 Rudolf Adamkovič
2023-06-05  5:27 ` Pedro Andres Aranda Gutierrez
2023-03-12 12:23 Timothy
2023-03-13 12:26 ` Ihor Radchenko
2023-03-14 16:04   ` Timothy
2023-03-15  9:34     ` Ihor Radchenko
2023-03-15 17:28       ` Rudolf Adamkovič
2023-03-13 12:30 ` Ihor Radchenko
2023-03-13 12:32   ` Ihor Radchenko
2023-03-14 14:46     ` Timothy
2023-03-13 12:36 ` Ihor Radchenko
2023-03-14 16:10   ` Timothy
2023-03-15  9:38     ` Ihor Radchenko
2023-03-13 12:37 ` Ihor Radchenko
2023-03-14 16:13   ` Timothy
2023-03-25 15:29 ` Tony Zorman
2023-05-02 12:15 ` K. Chousos
2023-05-03 10:07 ` K. Chousos
2023-05-05 17:57   ` Karthik Chikmagalur
2023-05-05 18:48     ` Konstantinos Chousos
2023-05-05 18:53     ` Konstantinos Chousos
2023-05-05 20:05       ` Karthik Chikmagalur
2023-05-05 21:06         ` Konstantinos Chousos
2023-05-05 22:58           ` Karthik Chikmagalur
2023-05-06  9:19             ` Konstantinos Chousos
2023-05-06  9:30               ` Ihor Radchenko
2023-05-06 10:08               ` Konstantinos Chousos
2023-05-08 20:04               ` Karthik Chikmagalur
2023-05-08 20:40                 ` Konstantinos Chousos
2023-05-09 11:34                 ` Ihor Radchenko
2023-05-09 12:03                   ` Timothy
2023-05-09 12:10                     ` Ruijie Yu via General discussions about Org-mode.
2023-05-09 12:12                     ` Ihor Radchenko
2023-05-09 12:10                       ` Timothy
2023-05-09 12:49                   ` Max Nikulin
2023-05-09 12:57                     ` Ihor Radchenko
2023-05-10 10:07 ` Jun Inoue
2023-05-10 10:21   ` Timothy
2023-05-10 13:09     ` Jun Inoue
2023-05-26  9:50 ` Rudolf Adamkovič
2023-05-28 17:31   ` Timothy
2023-06-03  9:00     ` Rudolf Adamkovič
2023-08-21  8:59 ` Visuwesh
2023-08-21 16:40   ` Karthik Chikmagalur
2023-08-21 17:19     ` Visuwesh
2023-08-21 21:40       ` Karthik Chikmagalur
2023-08-22  2:57         ` Visuwesh
2024-05-30  8:28         ` Visuwesh
2023-08-29  6:01 ` Roshan Shariff
2024-01-07  7:28 ` Timothy
2024-01-20  5:53 ` Matt Huszagh
2024-01-20  6:02 ` Matt Huszagh
2024-01-20  7:13   ` Matt Huszagh
2024-01-21 17:08     ` Timothy
2024-07-21 12:41 ` Jun Inoue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+ZA8QxpfyHAXivuqtQDFuAY4WWikwDmpTib2-hyryoPWwt=tw@mail.gmail.com' \
    --to=jun.lambda@gmail.com \
    --cc=drachov.yaroslav@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=karthikchikmagalur@gmail.com \
    --cc=orgmode@tec.tecosaur.net \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).