Skip to content

use project-relative path when previewing quarto documents - #18203

Merged
kevinushey merged 2 commits into
mainfrom
bugfix/18197-quarto-preview-working-dir
Jul 14, 2026
Merged

kevinushey merged 2 commits into
mainfrom
bugfix/18197-quarto-preview-working-dir

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Summary

Clicking the Render button on a Quarto document living within a sub-directory of a Quarto project failed with:

Error in rmarkdown:::abs_path(input) :
  The file 'claudetest.qmd' does not exist.

RStudio launched the preview job as quarto preview <filename> with the file's parent directory as the working directory. Newer versions of Quarto (reproduced with 1.9.38) fail to resolve a bare file name when previewing a file in a project sub-directory: the preview render step resolves the relative input against the project root rather than the process working directory. (Plain quarto render <filename> from the sub-directory works fine; the mis-resolution is specific to quarto preview.)

The fix runs the preview job from the Quarto project root (already known via the captured project config file) and passes a project-relative path -- i.e. quarto preview labs/doc.qmd from the project root, which is the same invocation that works from a terminal. Files not belonging to a Quarto project keep the previous behavior (file's parent directory as cwd), and a defensive fallback passes the absolute path if the target does not live under the computed working directory.

Note that this leaves chunk-evaluation working-directory semantics untouched: Quarto governs the execution directory itself (execute-dir), and RStudio's knit-directory preference does not flow into the quarto preview code path.

Testing

  • Reproduced the failure with quarto 1.9.38: quarto preview doc.qmd --to html --no-watch-inputs --no-browse run from a website project sub-directory fails with the error above; the same preview invoked from the project root with a project-relative path succeeds.
  • Added gtest coverage for the new previewWorkingDir() / previewTargetPath() helpers (project sub-directory, project root, non-project file, whole-project directory target, and the absolute-path fallback).
  • rstudio-tests --scope rsession passes (365 tests).

Fixes #18197.

@kevinushey kevinushey added this to the 2026.08 (Yellow Yarrow) milestone Jul 13, 2026
@posit-snyk-bot

posit-snyk-bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@kevinushey
kevinushey requested a review from gtritchie July 13, 2026 18:18

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
1800 0 76 3
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ desktop-linux 456 0 14 0
✅ desktop-macos 451 0 19 0
✅ desktop-windows 455 0 16 1
✅ server-linux 438 0 27 2
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit e33e7760432007c70d1a7bb6af7afc8bf1eabf5c - Run #158

@kevinushey
kevinushey merged commit fa7ecfe into main Jul 14, 2026
29 checks passed
@kevinushey
kevinushey deleted the bugfix/18197-quarto-preview-working-dir branch July 14, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render Button not working reliably

3 participants