quarto-dev / quarto-dev/quarto-cli

readInputTargetIndex cache validation ignores metadata-files, causing perpetual cache miss

Open
#14,227 0 comments 0 reactions 1 assignee View on GitHub

@cderv is already working on this.

Since Mar 18, 2026.

bug performance
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

readInputTargetIndex validates the on-disk index cache by reading the raw _quarto.yml and computing format keys:

https://github.com/quarto-dev/quarto-cli/blob/5b88d3dfe1519179e2e8753c44e058a11ab62ff3/src/project/project-index.ts#L174-L195

It does not resolve metadata-files before computing formatKeys(). When the format: configuration lives in a file referenced by metadata-files (e.g. _website.yml), formatKeys() returns [] while the cached index has the resolved formats (e.g. ["html"]). The comparison always fails, perpetually invalidating the cache.

This forces readBaseInputIndex to run for every project input on every render, even when nothing has changed. For projects with .R spin scripts, this triggers expensive knitr::spin() calls via R on every render.

Repro

Given this _quarto.yml:

project:
  type: website
metadata-files:
  - _website.yml

And _website.yml containing:

website:
  title: "test"
  navbar:
    left:
      - href: index.qmd
      - about.qmd
format:
  html:
    theme: [cosmo, brand]
    css: styles.css
    toc: true

Every quarto render index.qmd call rebuilds the index for all project inputs, because the cache check reads raw _quarto.yml (no format: key) and mismatches against the cached projectFormats: ["html"].

Moving the format: block into _quarto.yml makes the cache work correctly.

Full repro: https://github.com/byzheng/quarto-metadata-files-test

Context

Root cause of #14225. The effect is most visible when combined with .R spin scripts (each cache miss triggers 3 R process spawns), but the cache invalidation affects all projects using metadata-files for format configuration.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.