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

Quarto publish does not work with separate output-dir #5220

Closed
5 tasks done
AaronGullickson opened this issue Apr 17, 2023 · 5 comments
Closed
5 tasks done

Quarto publish does not work with separate output-dir #5220

AaronGullickson opened this issue Apr 17, 2023 · 5 comments
Assignees
Labels
bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Milestone

Comments

@AaronGullickson
Copy link

AaronGullickson commented Apr 17, 2023

Bug description

Vanilla projects (not book or website) cannot use the publish command correctly when a separate output directory is being used. This appears to be a consequence of not being able to correctly find the path to the output file. To reproduce, clone this template project and then run:

quarto publish quarto-pub analysis/analysis.qmd 

When I do this, I get the following output:

ERROR: NotFound: No such file or directory (os error 2), stat '/Users/aarong/projects/research-template/analysis/_products/analysis.html'

NotFound: No such file or directory (os error 2), stat '/Users/aarong/projects/research-template/analysis/_products/analysis.html'
    at Object.statSync (deno:runtime/js/30_fs.js:322:9)
    at file:///Applications/quarto/bin/quarto.js:121332:18
    at Array.reduce (<anonymous>)
    at normalizePublishFiles (file:///Applications/quarto/bin/quarto.js:121330:45)
    at renderForPublish (file:///Applications/quarto/bin/quarto.js:121282:24)
    at async renderForPublish (file:///Applications/quarto/bin/quarto.js:109061:24)
    at async handlePublish (file:///Applications/quarto/bin/quarto.js:108967:26)
    at async publishDocument (file:///Applications/quarto/bin/quarto.js:121321:38)
    at async publish5 (file:///Applications/quarto/bin/quarto.js:121417:132)
    at async doPublish (file:///Applications/quarto/bin/quarto.js:121373:13)

It appears that the problem has to do with how deeply nested the qmd files are in this case. Quarto seems to be expecting it to be only nested one level deep in the project directory structure and as a result tries to find the output directory in the analysis subdirectory rather than in the project root directory. Changing the project type to default and changing the execution directory to project had no effect on this error. Running the command from the analysis subdirectory also had no effect.

This is not working as of the nightly release v1.3.326 on RStudio 2022.12.0 Build 353 on Mac OSX.

Output of quarto check:

[✓] 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.326
      Path: /Applications/quarto/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.11.2
      Path: /Library/Frameworks/Python.framework/Versions/3.11/bin/python3
      Jupyter: 5.2.0
      Kernels: python3

(|) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.2.2
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
      knitr: 1.41
      rmarkdown: 2.18

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

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
  • Please provide the output of quarto check so we know which version of quarto and its dependencies you're running.
@AaronGullickson AaronGullickson added the bug Something isn't working label Apr 17, 2023
@allenmanning allenmanning added the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Apr 18, 2023
@allenmanning allenmanning assigned dragonstyle and unassigned cderv Apr 18, 2023
@dragonstyle dragonstyle added this to the v1.4 milestone Apr 18, 2023
@AaronGullickson
Copy link
Author

I wanted to add a note that tried setting the execution directory as the project directory in the _quarto.yml document and the bug persists.

@mcanouil
Copy link
Collaborator

mcanouil commented Jun 1, 2023

The issue in your case, is that you are in a project, and you try to publish a document inside the project as not part of the project, i.e., it's not currently possible to render/publish a file independently of the project as you want to do.
Also, valid projects are book or website, not a collection of documents at the moment.

On a side note, you might want to use renv instead of your check_packages.R script as a pre-render script.

The solution for your use case would be to use Project profile.

I made a PR showing this (and adding renv): AaronGullickson/research-template#1

@mcanouil
Copy link
Collaborator

mcanouil commented Jun 1, 2023

@dragonstyle Do you think there is something to be done in Quarto CLI here?

@AaronGullickson
Copy link
Author

Actually, rendering files independently of the project works fine. You can test this for yourself with:

quarto render analysis/analysis.qmd

This works fine and places the resulting analysis.html file into the _output directory as expected. Furthermore, the documentation on the quarto website is inconsistent with the claim that only books or websites are valid projects. Literally, everything else about my project works fine except for this important issue.

Your solution of using a separate _quarto-publish.yml file will allow it to be published but the resulting rendered output files then do not properly go to the _output directory which basically defeats the purpose of having an _output directory, which is to keep the project tidy and separate potential artifacts from scripts. Therefore, it will not work for my use case.

From my point of view, the fact that render works but publish does not suggests that this is not intended behavior and should be fixed. It also seems like it is a relatively straightforward problem of paths.

Let me explain my use case so you understand why this issue is important. It is not simply a "collection of files" but is designed for a very specific purpose. The purpose of this template is to provide a research template for academic researchers that focuses on transparency, openness, and replicability. Separating rendered output from scripts is critical as a logical step to identify rendered artifacts that may be out of date and should be removed prior to re-running the project. Everything works great at the moment, except for the publishing issue. Publishing is important because it allows collaborators (including ones who may not be directly involved in the coding) to see the most recent results from the project. Right now, I am literally having to email collaborators html files, which is extremely frustrating when I know there is a much easier way to do this.

@mcanouil
Copy link
Collaborator

mcanouil commented Jun 2, 2023

Ok, I know what's going on, the issue is when publishing document in sub-directories, i.e., the whole tree is in output-dir but this is not the path in the "publish" command.

In the end, this issue is related to #5765 in some aspects, i.e., sub-directories + output-dir does not work well at the moment.

  • quarto render analysis/analysis.qmd
_products/analysis/analysis.html
  • Current behaviour with quarto publish analysis/analysis.qmd
_products/analysis.html
  • Expected behaviour with quarto publish analysis/analysis.qmd
_products/analysis/analysis.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone.
Projects
None yet
Development

No branches or pull requests

5 participants