Project render fails with "Directory not empty (os error 39)" removing execute-results when the project is on NFS

未关闭
#15,054 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
javascript, linux, r

调研方向

Start in src/command/render/render-files.ts at renderExecute(), where removeFreezeResults() deletes the execute-results directory right after the freeze copy, and follow the call into safeRemoveSync(). The failure is an ENOTEMPTY race on NFS that cannot be reproduced on local disk, so first decide between a retry with backoff, a warning instead of a fatal error, or skipping the write when freeze is off. Done means a project render on NFS no longer aborts, with an existing test or a new one covering the removal path.

由索引模型根据 Issue 内容生成。

描述

bug file-systems
Bug description

Rendering a knitr document inside a Quarto project that lives on an NFS mount fails intermittently, after all code has executed and before pandoc runs:

processing file: analysis.qmd
output file: analysis.knit.md

ERROR: Directory not empty (os error 39): remove '/nfs/project/analyses/analysis_files/execute-results'

Stack trace:
    at Object.removeSync (ext:deno_fs/30_fs.js:250:3)
    at safeRemoveSync (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:3228:10)
    at removeIfExists (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:7970:5)
    at removeFreezeResults (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:136700:3)
    at renderExecute (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:136863:5)
    at async renderFileInternal (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:137094:35)
    at async renderFiles (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:136884:9)
    at async renderProject (file:///usr/lib/rstudio-server/bin/quarto/bin/quarto.js:137468:23)

Immediately afterwards, ls -la analysis_files/execute-results/ shows the directory is empty.

What seems to happen

In a project render, renderExecute() (src/command/render/render-files.ts) writes the freeze result <doc>_files/execute-results/html.json, copies it to the freezer, and then calls removeFreezeResults(), which removes execute-results right away (the project does not use freeze). On NFS, unlinking a file whose handle has not fully closed triggers the client's "silly rename": the file becomes a hidden .nfsXXXX placeholder until the last handle closes. The directory is therefore briefly non-empty, removeSync fails with ENOTEMPTY, and the render aborts. By the time a user inspects the directory, the placeholder is gone.

This fits the observations:

  • It happens after all code has run, so every chunk's side effects (saved files, figures) exist, but no HTML is written.
  • It is intermittent. The same document sometimes renders cleanly, and long documents with large output seem more affected.
  • It never happens with the same files on local disk.
  • It never happens outside a project (single-file renders take a different path that skips the freeze write).
Reproduction
  1. A Quarto project (_quarto.yml with project: type: default) on an NFS-mounted directory.
  2. A knitr .qmd with substantial printed output and a figure.
  3. quarto render path/to/doc.qmd repeatedly; some runs fail as above.

We cannot share our documents (clinical data), and the failure depends on NFS timing, so a minimal example on local disk will not reproduce it.

Workaround

Make execute-results a symlink to a directory on local disk before rendering:

files_dir="doc_files"
local_dir="$(mktemp -d)"
rm -rf "$files_dir" && mkdir -p "$files_dir"
ln -s "$local_dir" "$files_dir/execute-results"
quarto render doc.qmd

Quarto writes html.json through the link and, on cleanup, removes the link itself, so nothing is unlinked on NFS. The render then succeeds, with project mode and pre/post-render scripts intact. (Symlinking the whole _files directory instead does not work: the final cleanup refuses to remove a directory that resolves outside the project.)

Possible fixes
  • Retry the removal of execute-results on ENOTEMPTY/EBUSY with a short backoff, as many tools do for NFS.
  • Treat failure to remove execute-results as a warning rather than a fatal error, since the freeze result has already been copied to the freezer.
  • When freeze is not enabled, skip writing execute-results/html.json beside the document at all.
Environment
  • Quarto 1.10.18 (bundled with Posit Workbench)
  • R 4.6.1, knitr 1.51, rmarkdown 2.31
  • RHEL 8.10, project directory on an NFS mount
Related

#2380 also concerns projects on network storage, but it is a Windows UNC path-resolution failure (os error 3); this is a Linux NFS delete race (os error 39).

主要语言
JavaScript
星标
6.1k
派生
478
平均合并
17 小时 7 分钟
30 天内合并 PR
112

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

quarto-dev/quarto-cli 的其他 Issue

查看 quarto-dev/quarto-cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。