Error: Input files not all in same directory, please supply explicit wd

Error: Input files not all in same directory, please supply explicit wd

在尝试构建约 2 周前有效的 PDF 后,不用大惊小怪,在一台全新安装了 R、R studio、bookdown 等的新机器上,我遇到了这个错误:

Error: Input files not all in same directory, please supply explicit wd

我将 .Rmd 文件的章节分类到目录中,因此如果我将 rmd_subdirtrue 更改为 false,错误就会消失,但是.. . 我无法处理项目根目录中每个场景包含 4-7 个场景的 100 多个章节;我要疯了。

我的 _bookdown.yml 中有 new_session: no,但这无济于事。

我对 R 的了解还不够,甚至无法开始对此进行诊断 - Google returns 4 (!) results 而且所有这些都是源代码。因此,我不确定要在此处包含哪些文件,所以请告诉我,我会将它们粘贴进去。

我是如何建造的

我在 RStudio 中按下显示 Build Book 的按钮,它滴答作响并在片刻后退出并出现 status 1 和上述错误。

准确的错误信息

==> rmarkdown::render_site(output_format = 'bookdown::gitbook', encoding = 'UTF-8')



processing file: book-book.Rmd
  |......................................................................| 100%
  ordinary text without R code


output file: book-book.knit.md

Error: Input files not all in same directory, please supply explicit wd
Execution halted

Exited with status 1.

index.Rmd

---
title: "F"
author: "TTil"
site: bookdown::bookdown_site
fontsize: 10pt
geometry: paperwidth=6in,paperheight=9in,margin=0.5in,heightrounded,twoside,includehead,includefoot,heightrounded
output:
  bookdown::gitbook:
    split_by: section
    config:
      toolbar:
        position: static
  bookdown::pdf_book:
    keep_tex: yes
    latex_engine: lualatex
    includes:
      in_header: preamble.tex
      before_body: before_body.tex
documentclass: book
link-citations: yes
linestretch: 1.15
links-as-notes: true
mainfont: "Inter"
---

_bookdown.yml

book_filename: 'book-book'
language:
  ui:
    chapter_name: ''
delete_merged_file: true
new_session: no
rmd_subdir: true

# Before We Begin {-}

test test replace me

我的文件结构如下所示:

index.Rmd
  - part-1/
     - ch01/
       - sc01.Rmd
       - sc02.Rmd
       ...
     - ch02/
     ...
  - part-2/
  ... 

因此我希望 sc01.Rmdsc02.Rmd 成为 第一章, 然后它和它的兄弟姐妹成为 第一章, 等等 第二部分, 第三部分, ...

正如我上面所说,这个 PDF 在 2 周前就可以正常工作了(尽管在不同的机器上)。

干杯。

Update:这已在 bookdown 的开发版本中修复:https://github.com/rstudio/bookdown 您可以通过 remotes::install_github('rstudio/bookdown').


这可能与 a recent feature in bookdown 有关。由于您没有提供可重现的示例,我盲目猜测设置 options(bookdown.render.file_scope = FALSE) 可能会解决它。您可以在 Rmd 文档或 ~/.Rprofile.

中设置此选项

类似问题:命令 Rscript -e "bookdown::render_book(input='index.Rmd', output_format='bookdown::gitbook', config_file='_py-rse.yml')" 在 bookdown 0.19 的命令行中运行良好,但在 bookdown 0.20(今天安装)时失败,给出消息 Error: Input files not all in same directory, please supply explicit wd。配置文件 _py-rse.yml(下)确实在多个目录中有文件——我们必须这样做,因为我们在同一个项目中构建多本书(共享一些章节和附录)。我会在下次更新 bookdown 时再试一次;如果错误仍然存​​在,我将尝试创建一个 reprex。

book_filename: "py-rse"
language:
  label:
    fig: "Figure "
    tab: "Table "
  ui:
    chapter_name: "Chapter "
output_dir: "_book/py-rse"
delete_merged_file: false
rmd_files:
  - index.Rmd
  - py-rse/bash-basics.Rmd
  - py-rse/bash-advanced.Rmd
  - py-rse/scripting.Rmd
  - py-rse/git-cmdline.Rmd
  - py-rse/git-advanced.Rmd
  - py-rse/automate.Rmd
  - py-rse/config.Rmd
  - py-rse/errors.Rmd
  - py-rse/teams.Rmd
  - py-rse/style.Rmd
  - py-rse/project.Rmd
  - py-rse/testing.Rmd
  - py-rse/packaging.Rmd
  - py-rse/publish.Rmd
  - py-rse/finale.Rmd

  # End files
  - appendix.Rmd
  - LICENSE.md
  - CONDUCT.md
  - CONTRIBUTING.md
  - gloss.md
  - py-rse/install.Rmd
  - py-rse/objectives.Rmd
  - py-rse/keypoints.Rmd
  - py-rse/solutions.Rmd
  - py-rse/yaml.Rmd
  - py-rse/ssh.Rmd
  - references.Rmd
  - links.md

只是 的补充。如果我将行 options(bookdown.render.file_scope = FALSE) 添加到 R markdown 文件,它不起作用。如果将此行添加到 ~/.Rprofile 文件中,效果会很好。