nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
942 stars 48 forks source link

`(invalid-read-syntax "#" 1 0)` when exporting a transcluded file #137

Open maikol-solis opened 2 years ago

maikol-solis commented 2 years ago

Hi! I have this issue with org-transclusion with org-roam

Suppose you have these files

TEST1.org

:PROPERTIES:
:ID: 20220302T110131
:END:
#+TITLE: TEST1

TEST1

TEST2.org

:PROPERTIES:
:ID: 20220302T110150
:END:
#+TITLE: TEST2

#+transclude: [[id:20220302T110131][TEST1]] 

TEST2

If I run org-transclusion-mode in TEST2.org and then try to export the file to a pdf, I get this error in *Org Export Process* buffer

Debugger entered--Lisp error: (invalid-read-syntax "#" 1 0)
  read(#<buffer  *load*>)
  load-with-code-conversion("/private/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h00..." "/private/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h00..." nil t)
  command-line-1(("-l" "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/d..." "-l" "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/o..."))
  command-line()
  normal-top-level()

I tried the exporting without transcluding the first file and everything works as usual.

Thanks for the help.

nobiot commented 2 years ago

How can I reproduce this issue? I have no problem exporting to a PDF file with your test files.

I wonder why these files are being used in your error message; they have nothing to do with Org-transclusion:

Screenshot from 2022-03-02 20-11-22

maikol-solis commented 2 years ago

It's weird to me also.

I could capture the org-export-process file in /private/var/folder/...

https://pastebin.com/0D8N9ZtF

maikol-solis commented 2 years ago

More information. I debugged org-export-latex-to-pdf using trace-function.

In my config I have (setq org-export-in-background t) which lead me to though that the problem could come from the async exporting process.

First, I ran (org-export-latex-to-pdf t) (the t activates the async parameter).

This trigger the issue and the file isn't exported.

======================================================================
1 -> (org-latex-export-to-pdf t)
1 <- org-latex-export-to-pdf: #[514 "\302!\303!\304=\205B�\305\306\300\"\216\307!\310U\2034�\305\311\"\216r\211q\210db\210\312 \210\313p!)\301!\262)\202A�\314\315#\210\316 \210\317\320\")\207" ["/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/org-export-processfSXj49" #[257 "\301\302!\300\"\207" [latex org-export-add-to-stack expand-file-name] 4 "

(fn FILE)"] process-buffer process-status exit make-closure #[0 "   ?\205�\302\300!\207" [V0 org-export-async-debug delete-file] 2] process-exit-status 0 #[0 "    ?\205�\302\300!\205�\303\300!\207" [V0 org-export-async-debug get-buffer kill-buffer] 2] backward-sexp read org-export-add-to-stack nil ding message "Process `%s' exited abnormally"] 7 "

(fn P STATUS)"]

Then, I ran (org-export-latex-to-pdf nil) and all compiled perfectly.

======================================================================
1 -> (org-latex-export-to-pdf nil)
1 <- org-latex-export-to-pdf: "/Users/maikol/Dropbox/home/documents/org/roam/20220302T110150-test2.pdf"

image

My doom/info

``` generated Mar 02, 2022 15:14:53 system MacOS 11.6.3 Darwin 20.6.0 x86_64 ns emacs 28.0.91 HEAD c2fb07fdb ~/.emacs.d/ -> ~/.emacs.d/ doom 21.12.0-alpha HEAD -> master 42e576378 2022-02-23 17:49:53 +0100 ~/.doom.d/ -> ~/dotfiles/.doom.d/ shell /bin/zsh features ACL DBUS GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS XIM XWIDGETS ZLIB traits gui server-running envvar-file custom-file custom debug-on-error widget-image-enable warning-suppress-types x-underline-at-descent-line modules :completion (company +tng) (vertico +icons) :ui deft doom (&nopath fill-column) hl-todo hydra minimap modeline nav-flash ophints (popup +all +defaults) vc-gutter vi-tilde-fringe (window-select +numbers) workspaces zen :editor (evil +everywhere) file-templates fold format multiple-cursors snippets word-wrap :emacs (dired +icons) electric (ibuffer +icons) (undo +tree) vc :checkers syntax (spell +flyspell +everywhere) grammar :tools biblio ein (eval +overlay) (lookup +dictionary +offline +docsets) (lsp +peek) (magit +forge) pdf :os (tty +osc) macos :lang emacs-lisp (ess +lsp) (latex +latexmk +cdlatex +fold +lsp) (markdown +grip) (org +pomodoro +dragndrop +jupyter +present +noter +pandoc +pretty +roam2) (python +lsp) sh :email (mu4e +org +gmail) :app calendar :config (default +bindings +smartparens) packages (nano-theme) (nano-agenda) (mu4e-alert :disable t) (outline-minor-faces) (bicycle) (google-translate) (plantuml-mode) (graphviz-dot-mode) (org-super-agenda) (org-ql) (org-pomodoro-third-time :recipe (:host github :repo telotortium/org-pomodoro-third-time)) (org-alert) (org-fragtog) (laas) (real-auto-save) (git-auto-commit-mode) (org-roam-ui) (citar) (helm-bibtex) (org-ref) (org-transclusion) (polymode) (poly-R) (poly-markdown) (move-dup) (academic-phrases) (company-tabnine) (company-posframe) (el-secretario :recipe (:repo https://git.sr.ht/~zetagon/el-secretario :files (*))) (org-gtd) (org-edna) (org-agenda-property) (org-gcal :recipe (:host github :repo rhaps0dy/org-gcal.el) :pin 6ac62f796a2c) (dashboard) (keypression) (good-scroll) (svg-lib) unpin org-roam org-roam-bibtex ```
nobiot commented 2 years ago

What does org-export-stack give you?

In my case, these. I will try with emacs -Q later but I don't know if it is related to Org-transclusion...

Screenshot from 2022-03-03 07-57-16

maikol-solis commented 2 years ago

Yes you're right, there is something wrong with the export process as a whole. I changed the file to this

:PROPERTIES:
:ID: 20220302T110150
:END:
#+TITLE: TEST2

#+INCLUDE: "./20220302T110131-test1.org"

TEST2

And I got the same issue with the async export. :(

image

I checked org-stack-add-to-stack and I got this

======================================================================
1 -> (org-export-add-to-stack #<buffer *Org Export Process*<2>> nil #<process org-export-process>)
1 <- org-export-add-to-stack: ((#<buffer *Org Export Process*<2>> nil #<process org-export-process>) (#<buffer *Org Export Process*> nil #<process org-export-process>))
maikol-solis commented 2 years ago

Using emacs -Q and exporting asynchronously, I got this

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  make-process(:name "org-export-process" :buffer "*Org Export Process*<3>" :command ("/Applications/Emacs.app/Contents/MacOS/Emacs" "--batch" "-l" nil "-l" "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/o..."))
  start-process("org-export-process" "*Org Export Process*<3>" "/Applications/Emacs.app/Contents/MacOS/Emacs" "--batch" "-l" nil "-l" "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/o...")
  org-export-async-start(#f(compiled-function (file) #<bytecode 0x1101dc9ff990871e>) (let ((output (org-export-as 'latex nil nil nil '(:output-file "20220302T110150-test2.tex")))) (with-temp-buffer (insert output) (let ((coding-system-for-write 'undecided-dos)) (write-file "20220302T110150-test2.tex"))) (or (ignore-errors (funcall 'org-latex-compile "20220302T110150-test2.tex")) "20220302T110150-test2.tex")))
  org-export-to-file(latex "20220302T110150-test2.tex" t nil nil nil nil org-latex-compile)
  org-latex-export-to-pdf(t)
  eval-expression((org-latex-export-to-pdf t) nil nil 127)
  funcall-interactively(eval-expression (org-latex-export-to-pdf t) nil nil 127)
  command-execute(eval-expression)

When debugging make-process I got this:

 ======================================================================
1 -> (make-process :name "org-export-process" :buffer "*Org Export Process*<6>" :command ("/Applications/Emacs.app/Contents/MacOS/Emacs" "--batch" "-Q" #1="-l" "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/doom-org-async-export1jeHlP" #1# "/var/folders/4d/qj4qr8zx1n36td0hlt0p7x_h0000gn/T/org-export-processRhsiVz"))
1 <- make-process: #<process org-export-process>

This is as far as I've gotten.

nobiot commented 2 years ago

I have tried exporting to pdf with emacs -Q. Even without Org-transclusion in the buffer, I get this error when I evaluate (org-latex-export-to-pdf t). Evaluating (org-latex-export-to-pdf) produces a PDF file correctly.

Screenshot from 2022-03-03 18-06-31

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  make-process(:name "org-export-process" :buffer "*Org Export Process*<8>" :command ("/usr/local/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processAwwHgD"))
  start-process("org-export-process" "*Org Export Process*<8>" "/usr/local/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processAwwHgD")
  org-export-async-start(#f(compiled-function (file) #<bytecode 0x12409a2f5a93505e>) (let ((output (org-export-as 'latex nil nil nil '(:output-file "2022-01-08T221056.tex")))) (with-temp-buffer (insert output) (let ((coding-system-for-write 'undecided-unix)) (write-file "2022-01-08T221056.tex"))) (or (ignore-errors (funcall '#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_83> "2022-01-08T221056.tex")) "2022-01-08T221056.tex")))
  org-export-to-file(latex "2022-01-08T221056.tex" t nil nil nil nil #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_83>)
  org-latex-export-to-pdf(t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

I don't use export or export in the async mode. I am not sure if I am using the async mode correctly, but as I get the error without Org-transclusion mode, I think the issue is outside Org-transclusion. I cannot look at it further.

I suggest you report this issue with Org development mailing list.

maikol-solis commented 2 years ago

Thanks! It looks like the async export process is broken in org-mode. At least there is not something in org-transclusion. Sorry for the noise.

nobiot commented 2 years ago

No problem! I also checked the temp file written for the async process to export with Org-transclusion on. It had the transcluded contents. So I guess as long as Org export works, it should work. This does not explain why it worked for you if you switch off Org-transclusion....

maikol-solis commented 1 year ago

Hi @nobiot. I'm searching for this bug again, and I found that apparently it has relation with polymode

https://list.orgmode.org/aw_wwlJcCuUcOWTA5vHxOQaat4W5s33Auov2jBSfrpkgCoM2JuGIUN6WNDQMfBYQL2NQog7cewykBnCPQa2ZuRr0Nc0mwyf4A_yEyYvxxZM=@protonmail.com/

nobiot commented 1 year ago

Okay, so you raises an issue in polymode. Thanks. I didnt see any relevant issue there after the org mailing list you referenced.

At the moment, I am afraid I cannot do anything.

Thank you for circling back :)

maikol-solis commented 1 year ago

No problem at all. Thanks for your patience.

Of course, the issue isn't related to org-transclusion at all, but the debug output here could be valuable if anyone wants to review it.

Best.