Skip to content

feat: provide guidance if tmp csv file is not found in Quarto rendering#1176

Open
avehtari wants to merge 3 commits intomasterfrom
fix-1012-help-with-quarto-cache
Open

feat: provide guidance if tmp csv file is not found in Quarto rendering#1176
avehtari wants to merge 3 commits intomasterfrom
fix-1012-help-with-quarto-cache

Conversation

@avehtari
Copy link
Copy Markdown
Member

@avehtari avehtari commented Apr 8, 2026

Quarto caches the fit object which has paths to the output csv files. By default the output csv files are in tmp directory which gets removed when rendering stops. Cache works if the cmdstanr_output_dir is not a temporary directory. Set cmdstanr_output_dir before creating the fit object

options(cmdstanr_output_dir = desired_path_to_a_non_temporary_directory)

This PR adds an informative message if the csv file is not found, running knitr, and file path has "/tmp"

This PR is pure organic without any AI assistance

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):

Aki Vehtari

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

@avehtari avehtari requested a review from jgabry April 8, 2026 18:38
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.19%. Comparing base (801b2b4) to head (543980c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1176      +/-   ##
==========================================
- Coverage   91.23%   91.19%   -0.05%     
==========================================
  Files          15       15              
  Lines        6070     6050      -20     
==========================================
- Hits         5538     5517      -21     
- Misses        532      533       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jgabry jgabry linked an issue Apr 8, 2026 that may be closed by this pull request
@avehtari
Copy link
Copy Markdown
Member Author

avehtari commented Apr 9, 2026

I modified the condition, added explanation to options.R, and added a test for the knitr behavior

csv_file_exists <- check_file_exists(files, access = "r", extension = "csv")
if (!isTRUE(csv_file_exists)) {
if (isTRUE(getOption("knitr.in.progress")) &&
is.null(getOption("cmdstanr_output_dir")) &&
Copy link
Copy Markdown
Member

@jgabry jgabry Apr 9, 2026

Choose a reason for hiding this comment

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

It occurs to me that this is checking the option value at read time but what matters is what the option value was at run time.

If between the first render of the document and the later rerender if the user has since set cmdstanr_output_dir then this message will be suppressed.

I have an idea for how we can handle this. I will make some commits when I have time.

Copy link
Copy Markdown
Member

@jgabry jgabry Apr 9, 2026

Choose a reason for hiding this comment

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

I just opened PR #1178, which takes a different approach to this that avoids this particular problem. Let me know what you think. One issue is that my version solves this problem but is more complicated. If we can figure out how to make your version work then I would prefer that to my version.

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.

Errors re-rendering quarto html with cached chunks and cmdstanr.

3 participants