quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.9k stars 322 forks source link

Getting file not found errror when setting `revealjs` setting #6809

Open hamelsmu opened 1 year ago

hamelsmu commented 1 year ago

Bug description

In my _quarto.yml file, if I add these options:

format:
  html:
    code-copy: true
    theme: cosmo
    css: styles.css
+  revealjs: 
+    code-line-numbers: false

I get the following error

ERROR: NotFound: No such file or directory (os error 2), rename '/Users/hamel/github/embed-debug-quarto/1_setup/index.html' -> '/Users/hamel/github/embed-debug-quarto/_site/1_setup/index.html'

NotFound: No such file or directory (os error 2), rename '/Users/hamel/github/embed-debug-quarto/1_setup/index.html' -> '/Users/hamel/github/embed-debug-quarto/_site/1_setup/index.html'
    at Object.renameSync (deno:runtime/js/30_fs.js:175:9)
    at renderProject (file:///Applications/quarto/bin/quarto.js:86832:22)
    at async Command.fn (file:///Applications/quarto/bin/quarto.js:90856:32)
    at async Command.execute (file:///Applications/quarto/bin/quarto.js:8437:13)
    at async quarto (file:///Applications/quarto/bin/quarto.js:127545:5)
    at async file:///Applications/quarto/bin/quarto.js:127563:9

Steps to reproduce

I have made a minimal repro here

I am using Quarto 1.3.450

To repro, do the following:

git clone https://github.com/hamelsmu/embed-debug-quarto.git
quarto render

Expected behavior

No response

Actual behavior

No response

Your environment

Quarto check output

[✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.1: OK Dart Sass version 1.55.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.3.450 Path: /Applications/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK Version: 3.10.12 (Conda) Path: /Users/hamel/mambaforge/bin/python Jupyter: 5.3.0 Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK Version: 4.0.4 Path: /Library/Frameworks/R.framework/Resources LibPaths:

[✓] Checking Knitr engine render......OK

cc: @jjallaire @cscheid

cscheid commented 1 year ago

I can repro that here as well. Wild.

cscheid commented 1 year ago

(I think @dragonstyle did our line numbering support)

hamelsmu commented 1 year ago

I can repro that here as well. Wild.

😄 Thank you. I thought I was losing my mind! Hahaha the error didn't make any sense in relation to what I was changing, that is why it took so long for me to isolate this!

cderv commented 1 year ago

FWIW nothing to do with code-line-numbers as I can repro just by adding revealjs: default to the format with same error

same error message ```` > quarto render [1/3] 1_setup\1-setup.qmd [2/3] 1_setup\index.qmd [3/3] index.qmd ERROR: NotFound: Le fichier spécifié est introuvable. (os error 2): rename 'C:\Users\chris\AppData\Local\Temp\quarto\embed-debug-quarto\1_setup\index.html' -> 'C:\Users\chris\AppData\Local\Temp\quarto\embed-debug-quarto\_site\1_setup\index.html' Stack trace: at Object.renameSync (ext:deno_fs/30_fs.js:215:7) at renderProject (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/project.ts:332:14) at eventLoopTick (ext:core/01_core.js:181:11) at async Command.fn (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/cmd.ts:212:26) at async Command.execute (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/x/cliffy@v0.25.4/command/command.ts:1790:7) at async quarto (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:135:3) at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:167:5 ````

I think what happens is a conflict betwen html and revealjs that both aim to output some HTML files. Those two formats produce HTML so they overwrite each other, but in the case of a project rendering with output-dir set, the moving of file raises an error, because there is only one file to move as both formats have written to the same file.

Here the detailed explanation of why this happens (not sure you are expecting this behavior)

Format metadata merging

Regarding this usage in _quarto.yml, it will be merged with document level format, and I believe this part of the doc is important

Note that when metadata is combined, objects and arrays are merged rather than simply overwriting each other. (...) The one exception to metadata merging is format. If the document-level YAML defines a format, it must define the complete list of formats to be rendered.

This means to me that if no format is defined at a document level, then both from _quarto.yml level will be used. The file from the error (https://github.com/hamelsmu/embed-debug-quarto/blob/main/1_setup/index.qmd) does not get a format key, so I think it will be rendered to format: html and format: revealjs, and the fact that both produce html makes something trip.

Setting

---
title: "Setup"
order: 1
format: html
---

in the file remove the error.

Also to verify what I am saying you could try not setting a format in the Document level and use pdf in _quarto.yml

format:
  html:
    code-copy: true
    theme: cosmo
    css: styles.css
  pdf: default

After quarto render, a pdf file for 1_setup/index.qmd will be produced. Now add back the format: html in this qmd file -> No PDF file is rendered at all. The format for pdf defined in _quarto.yml is completely ignored by quarto render because

This happens at https://github.com/quarto-dev/quarto-cli/blob/ea8942094ad670ccbb9d6f8fcafc4bcf097aa7cc/src/command/render/render-contexts.ts#L448-L454

This way of merging project formats with other format metadata is the default one - only book project only consider project format only.

About the missing index.html

I believe this is the same as https://github.com/quarto-dev/quarto-cli/issues/4470 for revealjs and HTML, and close to https://github.com/quarto-dev/quarto-cli/issues/1929 about multiple markdown output format

Quarto currently have no way to track all this correctly and so a format producing .html will overwrite a previous one producing also a .html (Next big improvement probably - https://github.com/quarto-dev/quarto-cli/issues/6518)

Error is from https://github.com/quarto-dev/quarto-cli/blob/ea8942094ad670ccbb9d6f8fcafc4bcf097aa7cc/src/command/render/project.ts#L328-L333 and this happens for each output file. format: html and format: revealjs have the same output file, so it errors because there is only one to move

Anyhow, sorry for long post. It is not the first time this happens so now we have a written explanation until https://github.com/quarto-dev/quarto-cli/issues/6518 helps us solve all this.