Skip to content

rmarkdown uses incorrect working directory if filename has spaces and output format is "github_document" #1980

@cboettig

Description

@cboettig

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.


As you can in the reprex below, all this does is create a trivial Rmarkdown document in a subdirectory, and then attempt to knit it. Because the RMarkdown document has a space in the name and we have requested github_document, the example errors by having the wrong working directory (the root dir, not the same dir from where the Rmarkdown file is found, as in the usual convention!) Change the output format to html_document, or remove the space in the name, and the error is resolved.

Consider the following reprex:

dir.create("subdir")
download.file("https://gist.githubusercontent.com/cboettig/5ba7013764152c1305bf26d81ec94fbe/raw/0b23bc008f816fdb80f9744da35d7ee78ba5ce4a/Bug%2520Report.Rmd",
"subdir/Bug Report.Rmd")
rmarkdown::render("subdir/Bug Report.Rmd")
#> processing file: Bug-Report.Rmd
#> Quitting from lines 8-10 (Bug-Report.Rmd)
#> Error: file.exists("Bug Report.Rmd") is not TRUE

Created on 2020-12-14 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviortheme: pathspath related improvment / issue

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions