Skip to content

quarto_inspect() should forward error message #768

Closed as not planned
Closed as not planned
@salim-b

Description

@salim-b

Currently, quarto_inspect() does not forward the error message when it fails:

Sys.setenv(NO_COLOR = "1")

# create new quarto book project
path_tmp <- tempdir()
path_tmp_proj <- file.path(path_tmp, "test")

quarto::quarto_create_project(name = "test",
                              type = "book",
                              dir = path_tmp,
                              no_prompt = TRUE)
#> WARN: No 'title' for project provided in `quarto create project`. Using 'test' as default.
#> Creating project at /tmp/Rtmpin5zHs/test:
#>   - Created _quarto.yml
#>   - Created index.qmd
#>   - Created intro.qmd
#>   - Created summary.qmd
#>   - Created references.qmd
#>   - Created cover.png
#>   - Created references.bib

# quarto inspect runs successfully
quarto::quarto_inspect(input = path_tmp_proj) |> is.list()
#> [1] TRUE

# rename intro chpt file to trigger error
file.rename(from = file.path(path_tmp_proj, "intro.qmd"),
            to = file.path(path_tmp_proj, "no_intro.qmd"))
#> [1] TRUE

# now quarto inspect fails – without forwarding the error
quarto::quarto_inspect(input = path_tmp_proj)
#> Error in `quarto::quarto_inspect()`:
#> ✖ Error running quarto cli.
#> Caused by error:
#> ! System command 'quarto' failed

Created on 2025-04-29 with reprex v2.1.1

The error message emitted by the underlying quarto inspect is the following in the above case:

$ quarto inspect /tmp/Rtmpin5zHs/test
ERROR: Book chapter 'intro.qmd' not found

Stack trace:
    at throwInputNotFound (file:///opt/quarto/bin/quarto.js:100761:19)
    at findInputs (file:///opt/quarto/bin/quarto.js:100792:17)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async findChapters (file:///opt/quarto/bin/quarto.js:100804:13)
    at async bookRenderItems (file:///opt/quarto/bin/quarto.js:100807:5)
    at async Object.bookProjectConfig [as config] (file:///opt/quarto/bin/quarto.js:100712:25)
    at async projectContext (file:///opt/quarto/bin/quarto.js:82390:38)
    at async inspectConfig (file:///opt/quarto/bin/quarto.js:110378:21)
    at async Command.actionHandler (file:///opt/quarto/bin/quarto.js:110497:20)
    at async Command.execute (file:///opt/quarto/bin/quarto.js:8253:13)

ERROR: Book chapter 'intro.qmd' not found immediately indicates what's the problem, so we should really forward it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions