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_render() throws an uninformative error when output is an absolute path #126

Closed
gadenbuie opened this issue Oct 6, 2023 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@gadenbuie
Copy link

gadenbuie commented Oct 6, 2023

In renderthis we do something that's equivalent to quarto_render("slides.qmd", output = tempfile(fileext = ".html")). (Sidenote: this certainly worked at some point, but is now failing.)

By default, in this scenario, the error will read:

quarto_render("slides.qmd", output = tempfile(fileext = ".html"))
#> Error in "processx::run(quarto_bin, args, echo = TRUE)" : 
#>   ! System command 'quarto' failed

but with quiet = FALSE we uncover the underlying error (the message it uncovers is, honestly, a bit confusing).

quarto_render("slides.qmd", output = tempfile(fileext = ".html"), quiet = FALSE)
#> ERROR: --output option cannot specify a relative or absolute path
#> 
#> Error: --output option cannot specify a relative or absolute path
#>   at parseRenderFlags (file:///Applications/quarto/bin/quarto.js:42392:31)
#>   at Command.fn (file:///Applications/quarto/bin/quarto.js:90845:25)
#>   at Command.execute (file:///Applications/quarto/bin/quarto.js:8437:24)
#>   at Command.parseCommand (file:///Applications/quarto/bin/quarto.js:8333:25)
#>   at async quarto (file:///Applications/quarto/bin/quarto.js:127540:5)
#>   at async file:///Applications/quarto/bin/quarto.js:127558:9

Edit: actually I realized our situation was slightly more nuanced. The temp file isn't in a different directory, but rather pointed to a location adjacent to the source input. Maybe quarto render previously allowed this scenario and is now more strict? Here's a better pseudo-reprex:

tmp_out <- file.path(getwd(), basename(tempfile(fileext = ".html")))
quarto_render("slides.Rmd", output = tmp_out)
@cderv
Copy link
Collaborator

cderv commented Oct 6, 2023

ERROR: --output option cannot specify a relative or absolute path

This is thrown from Quarto itself.

Are you suggesting this error message is unclear (in which case this is to solve in Quarto directly) or that we should add a check in this R package so that we stop early in such case as Quarto does not support this

Maybe quarto render previously allowed this scenario and is now more strict?

Yes this is it. Context at quarto-dev/quarto-cli#2440 (and probably quarto-dev/quarto-cli#2266 for the initial thing that #2440 was trying to fix)

@gadenbuie
Copy link
Author

Sorry, to be clear I meant that ! System command 'quarto' failed isn't very informative. At the least it could tell you to re-run quarto_render() with quiet = FALSE to see the underlying error. Or it might be better to collect the underlying error and chain with a more readable error from R?

Are you suggesting this error message is unclear (in which case this is to solve in Quarto directly) or that we should add a check in this R package so that we stop early in such case as Quarto does not support this

Maybe quarto_render() could help out with this? But I also understand we might not want the quarto package to be too restrictive and accidentally block supported behavior. So maybe just cleaner error chaining would help?

And thanks for the context links!

@cderv
Copy link
Collaborator

cderv commented Oct 6, 2023

Thanks for clarification !

@cderv cderv added this to the next version milestone Jan 23, 2024
@cderv cderv closed this as completed in 5a1aae2 Jan 23, 2024
@cderv
Copy link
Collaborator

cderv commented Jan 23, 2024

I went with adding a message to set quiet = FALSE. When quiet = TRUE quarto will return really nothing to play with. Only an error code.

@cderv cderv added the enhancement New feature or request label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants