Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

After trying to build a PDF that worked ~2 weeks ago, no fuss, on a new machine with a fresh install of R, R studio, bookdown, etc, I have this error:

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

I have chapters of .Rmd files sorted into directories, and so if I change rmd_subdir from true to false, the error goes away, but... I just can't work with 100+ chapters containing 4-7 each scenes in the root of the project; I'll go insane.

I have new_session: no in my _bookdown.yml, but that's not helping matters.

I don't know enough about R to even begin to diagnose this - Google returns 4 (!) results and all of them are source code. As such, I'm not sure which files to include here, so please let me know, and I'll paste them in.

How I Build

I press the button that says Build Book in RStudio, and it ticks along and exits with status 1 and the above error after a moment.

The exact error message

==> 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

My file structure looks like this:

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

and thus I expect sc01.Rmd and sc02.Rmd to become Chapter One, and then it and its siblings to be Part One, and so on and so forth for Part Two, Part Three, ...

As I've said above, this PDF was working as-is 2 weeksish ago (albeit on a different machine).

Cheers.

like image 493
hoobydooby Avatar asked Jun 25 '20 15:06

hoobydooby


2 Answers

Update: This has been fixed in the dev version of bookdown: https://github.com/rstudio/bookdown You can install it via remotes::install_github('rstudio/bookdown').


This might be related to a recent feature in bookdown. Since you didn't provide a reproducible example, my blind guess is that setting options(bookdown.render.file_scope = FALSE) might fix it. You can set this option in either your Rmd document or ~/.Rprofile.

like image 87
Yihui Xie Avatar answered Nov 14 '22 20:11

Yihui Xie


Just something complementary to Yihui's answer. If I added the line options(bookdown.render.file_scope = FALSE) to the R markdown file, it did not work. It worked great if this line was added to the ~/.Rprofile file.

like image 37
David Li Avatar answered Nov 14 '22 20:11

David Li