rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.86k stars 967 forks source link

pandoc: openFile: does not exist (No such file or directory) #1268

Open harryprince opened 6 years ago

harryprince commented 6 years ago

I am trying to server Rmd using shiny server. However, it seems rmarkdown or pandoc is buggy. It works well on Rstudio but fails deploy on rstudio connect too.

yaml config:

output:
  flexdashboard::flex_dashboard:
    social: menu
    source: embed
    storyboard: yes

Rmarkdown version:

 packageVersion("rmarkdown")
[1] ‘1.8’
shiny-server --version
Shiny Server v1.5.3.838
Node.js v6.10.0

pandoc version

/opt/shiny-server/ext/pandoc/pandoc --version
pandoc 1.12.3
Compiled with texmath 0.6.6, highlighting-kate 0.5.6.

sessionInfo():

R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

here is the shiny server log:

processing file: index.Rmd
output file: /tmp/rmarkdown/e01d3e5bbe48ef364e37eb0580046563/index.knit.md

pandoc: /tmp/RtmpWH829n/rmarkdown-str67a94810a85d.html: openFile: does not exist (No such file or directory)
Warning: Error in : pandoc document conversion failed with error 1
Stack trace (innermost first):
    115: pandoc_convert
    114: convert
    113: <Anonymous>
    112: do.call
    111: contextFunc
    110: .getReactiveEnvironment()$runWith
    109: shiny::maskReactiveContext
    108: <reactive>
     95: doc
     94: shiny::renderUI
     93: func
     92: force
     91: withVisible
     90: withCallingHandlers
     89: globals$domain$wrapSync
     88: promises::with_promise_domain
     87: captureStackTraces
     83: tryCatch
     82: do
     81: hybrid_chain
     80: origRenderFunc
     79: output$__reactivedoc__
      3: <Anonymous>
      2: do.call
      1: rmarkdown::run
yihui commented 6 years ago

Please test the development version:

devtools::install_github('rstudio/rmarkdown')

https://github.com/rstudio/blogdown/issues/256#issuecomment-365966430

harryprince commented 6 years ago

I tried to do it , however, it failed too and the error is the same as usual.

 devtools::install_github("rstudio/rmarkdown",lib="/usr/local/lib/R/site-library")
yihui commented 6 years ago

Are you sure R uses the rmarkdown package from /usr/local/lib/R/site-library? In other words, have you checked .libPaths() and are you sure /usr/local/lib/R/site-library is the first entry? When showing the session info, it will be great if you can load the package before showing it, e.g., either

library(rmarkdown)
sessionInfo()

or better (as requested in the issue template):

devtools::session_info('rmarkdown')
ADraginda commented 6 years ago

Just FYI I'm also seeing this error (trying to use rmarkdown with flexdashboard). Using the dev version unblocked things but I'm still seeing the error.

yihui commented 6 years ago

@ADraginda Are you also on Shiny Server? Is it reproducible locally?

NilsOle commented 6 years ago

I have the same issue, but only when I run rmarkdown::render(...) in parallel on multiple cores. When I do registerDoParallel(cores=1) it works without error. When running in parallel, out of many calls of the function, only some return errors as described here, and also not consistently (appears random at first sight). Is that information helpful?

To reproduce, install the following R package and 1) run reproducemarkdownerror:hello(3) for 3 cores respectively. This should give you error messages. 2) reproducemarkdownerror:hello(1) should not give you any errors.

reproducermarkdownerror_0.1.0.tar.gz

Output (operation produces only 92 files although 100 expected):

> reproducermarkdownerror::hello(3)
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124b12f90895.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124d5a2948a2.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124b1d015295.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124c3a9fd602.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124b191fe7b1.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124d70f14424.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124b586db239.html: openFile: does not exist (No such file or directory)
pandoc: /tmp/RtmpmiRJfV/rmarkdown-str124b142b5ab8.html: openFile: does not exist (No such file or directory)

 Error in do_rpt(r) : 
  task 7 failed - "pandoc document conversion failed with error 1"

Script taken from here: https://gist.github.com/hrbrmstr/17bc21af55392f23f012f57bb2fda51c

Version information:

> devtools::session_info("rmarkdown")
 setting  value                       
 version  R version 3.4.4 (2018-03-15)
 system   x86_64, linux-gnu           
 ui       RStudio (1.1.383)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       Europe/Berlin               
 date     2018-06-04                  

 package   * version date       source        
 backports   1.1.2   2017-12-13 CRAN (R 3.4.3)
 base64enc   0.1-3   2015-07-28 CRAN (R 3.4.3)
 digest    * 0.6.15  2018-01-28 CRAN (R 3.4.3)
 evaluate    0.10.1  2017-06-24 CRAN (R 3.4.3)
 glue        1.2.0   2017-10-29 CRAN (R 3.4.3)
 graphics  * 3.4.4   2018-03-16 local         
 grDevices * 3.4.4   2018-03-16 local         
 highr       0.6     2016-05-09 CRAN (R 3.4.3)
 htmltools   0.3.6   2017-04-28 CRAN (R 3.4.3)
 jsonlite    1.5     2017-06-01 CRAN (R 3.4.3)
 knitr       1.20    2018-02-20 CRAN (R 3.4.3)
 magrittr    1.5     2014-11-22 CRAN (R 3.4.3)
 markdown    0.8     2017-04-20 CRAN (R 3.4.3)
 methods   * 3.4.4   2018-03-16 local         
 mime        0.5     2016-07-07 CRAN (R 3.4.3)
 Rcpp        0.12.17 2018-05-18 CRAN (R 3.4.4)
 rmarkdown   1.9     2018-03-01 CRAN (R 3.4.3)
 rprojroot   1.3-2   2018-01-03 CRAN (R 3.4.4)
 stats     * 3.4.4   2018-03-16 local         
 stringi     1.2.2   2018-05-02 CRAN (R 3.4.4)
 stringr     1.3.1   2018-05-10 CRAN (R 3.4.4)
 tools       3.4.4   2018-03-16 local         
 utils     * 3.4.4   2018-03-16 local         
 yaml        2.1.19  2018-05-01 CRAN (R 3.4.4)
goldingn commented 6 years ago

I can reproduce this error locally. Using rmarkdown::pandoc_convert() to convert a file in the same directory works, but trying to convert it one directory down fails.

Create directory structure and file

dir <- tempdir()
sub_dir <- tempfile(tmpdir = dir)
f <- tempfile(tmpdir = sub_dir)
dir.create(sub_dir)
writeLines("This is a test", f)
cwd <- getwd()
library(rmarkdown)

This works

setwd(sub_dir)
fname <- basename(f)
readLines(fname)
#> [1] "This is a test"
pandoc_convert(fname, to = "html")

This doesn't:

setwd(dir)
fname <- file.path(basename(sub_dir), basename(f))
readLines(fname)
#> [1] "This is a test"
pandoc_convert(fname, to = "html")
#> Error: pandoc document conversion failed with error 1
setwd(cwd)
sessionInfo()
#> R version 3.5.1 (2018-07-02)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Sierra 10.12.6
#> 
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] rmarkdown_1.10.12
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.5.1  magrittr_1.5    htmltools_0.3.6 tools_3.5.1    
#>  [5] yaml_2.2.0      Rcpp_0.12.18    stringi_1.2.4   knitr_1.20     
#>  [9] htmldeps_0.1.1  digest_0.6.16   stringr_1.3.1   evaluate_0.11
AndrewManHayChiu commented 5 years ago

I had a similar problem, where I could knit in some directories, but not in others (on a mapped network drive).

I removed pandoc 2.4, to direct RStudio to use the in-built pandoc as per @yihui 's comment at #1184.

pauvasquezh commented 5 years ago

@NilsOle I'm having the same problem as you are describing, were you able to solve it somehow? :)

vthivierge commented 5 years ago

Following @pauvasquezh, @NilsOle or @goldingn were you able to solve this?

vthivierge commented 5 years ago

Following @pauvasquezh, @NilsOle or @goldingn were you able to solve this?

I solved it by changing my RStudio global options and setting the R version to be the local C:\ drive and not R on the network drive.

crossxwill commented 5 years ago

If the Rmd file is stored on a network drive, the knitting fails. However, if the Rmd file is stored on the local C:\ drive, the knitting works fine.

YAML

---
title: "Untitled"
author: "William Chiu"
date: "7/22/2019"
output: powerpoint_presentation
---

Network drive

output file: ppt_test.knit.md

"C:/Users/wchiu/AppData/Local/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS ppt_test.utf8.md --to pptx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output ppt_test.pptx 
pandoc.exe: ppt_test.utf8.md: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted

Local C:\ drive

"C:/Users/wchiu/AppData/Local/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS ppt_test.utf8.md --to pptx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output ppt_test.pptx 
output file: ppt_test.knit.md

Output created: ppt_test.pptx

Session Info

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  htmltools_0.3.6 tools_3.6.1     yaml_2.2.0      Rcpp_1.0.1      rmarkdown_1.14 
 [7] knitr_1.23      xfun_0.8        digest_0.6.20   evaluate_0.14  

RStudio Version

$citation

To cite RStudio in publications use:

  RStudio Team (2018). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL
  http://www.rstudio.com/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{RStudio Team}},
    organization = {RStudio, Inc.},
    address = {Boston, MA},
    year = {2018},
    url = {http://www.rstudio.com/},
  }

$mode
[1] "desktop"

$version
[1] ‘1.2.1335’
lamontbeau commented 5 years ago

Just save the Rmd file to the C:\ drive rather than desktop (Network Drive). This solved my problem while I have struggled a month... Very simple solution. Thank you guys.

crossxwill commented 5 years ago

@yihui - although there is a very simple work around (store Rmd file on C:\ rather than network drive), some of us are not allowed to save files on our C:\ (per company policy and/or using RStudio Server Pro with mounted network folders). Is there a plan to fix rmarkdown or knitr such that Rmd files that are stored on a network drive can still knit?

cderv commented 5 years ago

I think this is the same issue as in #701 where there is already a long discussion.

An issue was even opened to pandoc (jgm/pandoc#1326) as it is in fact a more general issue with pandoc than just Rmarkdown. it was conclude that it could come from the drive directly, and that it is not specific to R or Rmarkdown tools (https://github.com/rstudio/rmarkdown/issues/701#issuecomment-236960677)

Currently solution is to copy locally somewhere (not necessary in C:) before doing the conversion. see for example https://github.com/rstudio/rmarkdown/issues/701#issuecomment-237222070 or other comments.

To share experience, on a RStudio Server Pro (linux) with NFS mounted drive, we have no issue with that. Before I had issues with older system, and specifically with self_contained=TRUE document. Also, there was recently a specific fix for WINDOWS environment in https://github.com/jgm/pandoc/issues/5127 that is included in Pandoc 2.7.3. I don't know if it could help.

At the time, I manage to change some directory argument from Rmarkdown (https://github.com/rstudio/rmarkdown/issues/701#issuecomment-237182996) to get the intermediaries files on local drive. (my home directory was on local drive).

although there is a very simple work around (store Rmd file on C:\ rather than network drive), some of us are not allowed to save files on our C:\ (per company policy and/or using RStudio Server Pro with mounted network folders)

I think any local folder where you have access right will work. Not just C:/ . You could have a home directory or even a temp directory to move your file before knitting. (R has one in tempdir()) Moving files there before rendering could solve the issue with pandoc. Updating pandoc could help too maybe (rmarkdown::pandoc_version() to see what is shipped with your RStudio)

Hope it helps.

vnijs commented 5 years ago

FYI Seeing the same issue using Rstudio in a windows VM. Setting the default working directory in Rstudio to a drive letter (e.g., Z:) in "Tools > Global options > General" rather than the default "~" resolved the issue.

arielfuentes commented 5 years ago

I'm trying to do multiple reports (https://www.reed.edu/data-at-reed/software/R/markdown_multiple_reports.html) and with mtcars works fine, but if I do the same with my own dataframe loaded from a *.csv doesn't work. I don't know how to fix it nor I understand why and how is happening, I'm on a local computer.

sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 [4] LC_NUMERIC=C LC_TIME=Spanish_Spain.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] readr_1.1.1 stringr_1.3.1 leaflet_2.0.2 dplyr_0.8.3 ggplot2_3.1.1 rmarkdown_1.10 markdown_0.8
[8] knitr_1.20

loaded via a namespace (and not attached): [1] Rcpp_1.0.1 pillar_1.3.1 compiler_3.5.0 later_0.7.5 plyr_1.8.4 tools_3.5.0
[7] digest_0.6.18 evaluate_0.10.1 tibble_2.1.3 gtable_0.2.0 pkgconfig_2.0.2 rlang_0.4.0
[13] cli_1.0.1 shiny_1.1.0 rstudioapi_0.7 crosstalk_1.0.0 yaml_2.1.19 withr_2.1.2
[19] hms_0.4.2 htmlwidgets_1.3 rprojroot_1.3-2 grid_3.5.0 tidyselect_0.2.5 glue_1.3.1
[25] R6_2.2.2 fansi_0.4.0 purrr_0.2.5 magrittr_1.5 promises_1.0.1 scales_1.0.0
[31] backports_1.1.2 htmltools_0.3.6 rsconnect_0.8.15 assertthat_0.2.0 xtable_1.8-3 mime_0.5
[37] colorspace_1.3-2 httpuv_1.4.5 utf8_1.1.4 stringi_1.2.2 lazyeval_0.2.1 munsell_0.5.0
[43] crayon_1.3.4

Joe-Wasserman commented 5 years ago

I encountered the same error knitting to HTML from an .Rmd on a network drive. My working directory was already local. However, clearing the knitr cache resolved the issue.

jacobgellman commented 4 years ago

The solution by @vthivierge worked for me.

knjpollard commented 4 years ago

100% fix

when you open a project on a mapped drive do not open it through the shortcut to the mapped drive

this works and happens automatically when you open the Rstudio project through that path

rmarkdown::render('H:/Mediasonic/John/tester.Rmd', encoding = 'UTF-8');

this is what happens when you open it wrong the knit command cannot operate on this path rmarkdown::render('//offfice//H//Mediasonic RAID1//John/tester.Rmd', encoding = 'UTF-8');

knjpollard commented 4 years ago

Watch out used open file in recents and in "Quick Access" in windows 10 when opening Rstudio projects always brows to the actual mapped drive letter or set up a short cut that explicitly does that.

vliublinska commented 4 years ago

Watch out used open file in recents and in "Quick Access" in windows 10 when opening Rstudio projects always brows to the actual mapped drive letter or set up a short cut that explicitly does that.

Thank you!! This solved it for me.

vickibendus commented 4 years ago

I'm having the same issue on a Mac. Would anyone be able to assist on how to map the files properly to overcome this glitch since there is no C:/ drive? It seems like the solution is possible but I can't get it to work on my system! Thank you!

Joe-Wasserman commented 4 years ago

You can use "~/" as a shortcut for home directory, or you can refer to the absolute path, which will be something like /Users/Vicki , /Users/[your username on the machine]

Joe Wasserman joe.wasserman@gmail.com https://www.joewasserman.com

On Thu, Jan 2, 2020 at 3:56 PM vickibendus notifications@github.com wrote:

I'm having the same issue on a Mac. Would anyone be able to assist on how to map the files properly to overcome this glitch since there is no C:/ drive? It seems like the solution is possible but I can't get it to work on my system! Thank you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rstudio/rmarkdown/issues/1268?email_source=notifications&email_token=AH4TPUVHQKESIT2NTR3MX43Q3ZIHBA5CNFSM4ESHCZKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH7MM3I#issuecomment-570345069, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH4TPURW7GAVR35JJ7ZDU53Q3ZIHBANCNFSM4ESHCZKA .

vickibendus commented 4 years ago

Shoot that doesn't seem to be a solution for me then. My current working directory is "/Users/vickibendus/Desktop/R Materials/Soccer Reports", which appears to be the correct type of path. I'll have to keep searching for a way around this problem.

haroldgil commented 4 years ago

None of the solutions above have worked for me unfortunately. In my case, what confuses me is that the .Rmd file is converted to a .knit.md file which I cannot find (perhaps it's deleted since the rendering fails. My other question is why does pandoc get applied to a .utf8.md file if what was explicitly created was instead a .knit.md file. Perhaps a .utf8.md file is also created but I also cannot find this file (again it may just be deleted when rendering fails).

image

I've taken the long pandoc command and have manually edited the paths to look more like C:/etc. This would work fine except that these .knit.md and .utf8.md files are not available so the error regarding openBinaryFile seems to be simply because it can't find these files (perhaps because they're automatically deleted but maybe not). Does anyone know where these files would temporarily exist at least?

yihui commented 4 years ago

@haroldgil To avoid deletion of the intermediate files, you may call rmarkdown::render('matt.Rmd', clean = FALSE).

haroldgil commented 4 years ago

I found an easy solution in my case worth sharing. Again the problem seems to stem from the odd representation of a network drive directory. This directory comes into play in the pandoc command because pandoc() seems to indirectly rely on Sys.getenv('R_USER').

image

This directory is equivalent to my directory H:/ Thus I created a .Renviron file in H:/ and included in it the single entry R_USER=H:/ I restarted RStudio and the knitting works fine now. Also, looking at the pandoc command, all the weird references to the long/weird representation of H:/ (see image) have been replaced simply with H:/ indicating to me that pandoc() indeed relies on the value of Sys.getenv('R_USER').

RemKamal commented 4 years ago

I tried most of the suggestions above and it did not work.

I did know I had two paths in .libpaths() and I suspected it was causing the problem. One of the paths It referred to one old R/RStudio (it happened to be on network disk H in my case). It was almost fully deleted folder with a few files, and it was causing the problem.

How to navigate to/find paths is explained here: https://www.accelebrate.com/library/how-to-articles/r-rstudio-library I just did this: .libPaths(myPaths[2]) # keep only an importnat path (to local disk, in my case) and removed unwanted directory on disk H.

Then, I checked in "Install packages" of RStudio that the second path has disappeared and is absent.

After that KNIT-ing one my one I found all the missing packages it complained about. Those which my primary path to C drive did not have. After I installed it, it is working.

It is funny and sad at the same time, even though second path was not default, it was the root of the problem. Only removing files on H and also paths to that H in .libpaths() - HELPED!

jackhannah95 commented 4 years ago

I found an easy solution in my case worth sharing. Again the problem seems to stem from the odd representation of a network drive directory. This directory comes into play in the pandoc command because pandoc() seems to indirectly rely on Sys.getenv('R_USER').

image

This directory is equivalent to my directory H:/ Thus I created a .Renviron file in H:/ and included in it the single entry R_USER=H:/ I restarted RStudio and the knitting works fine now. Also, looking at the pandoc command, all the weird references to the long/weird representation of H:/ (see image) have been replaced simply with H:/ indicating to me that pandoc() indeed relies on the value of Sys.getenv('R_USER').

I plumbed the depths of Google to find a fix for this problem (on Windows 10) and this was it. My Sys.getenv("R_USER") location was a network drive, as was the (different) location of my R project and the .Rmd file I was trying to knit. My steps to fix were:

  1. Mapped the Sys.getenv("R_USER") location to my H:/ directory (pretty much any letter would've done).
  2. Ran usethis::edit_r_environ() and added R_USER=H:/ to it.
  3. Restarted RStudio.
  4. Re-ran Sys.getenv("R_USER") to ensure it was now H:/.
  5. Mapped the location of my R project to my G:/ directory (again most letters would've done).
  6. Opened the R project from my G:/ directory (either via the shortcut or by typing the path out; both worked for me) instead of the network drive.

Hope this is able to help someone else in future.

geopang commented 4 years ago

I found an easy solution in my case worth sharing. Again the problem seems to stem from the odd representation of a network drive directory. This directory comes into play in the pandoc command because pandoc() seems to indirectly rely on Sys.getenv('R_USER'). image This directory is equivalent to my directory H:/ Thus I created a .Renviron file in H:/ and included in it the single entry R_USER=H:/ I restarted RStudio and the knitting works fine now. Also, looking at the pandoc command, all the weird references to the long/weird representation of H:/ (see image) have been replaced simply with H:/ indicating to me that pandoc() indeed relies on the value of Sys.getenv('R_USER').

I plumbed the depths of Google to find a fix for this problem (on Windows 10) and this was it. My Sys.getenv("R_USER") location was a network drive, as was the (different) location of my R project and the .Rmd file I was trying to knit. My steps to fix were:

  1. Mapped the Sys.getenv("R_USER") location to my H:/ directory (pretty much any letter would've done).
  2. Ran usethis::edit_r_environ() and added R_USER=H:/ to it.
  3. Restarted RStudio.
  4. Re-ran Sys.getenv("R_USER") to ensure it was now H:/.
  5. Mapped the location of my R project to my G:/ directory (again most letters would've done).
  6. Opened the R project from my G:/ directory (either via the shortcut or by typing the path out; both worked for me) instead of the network drive.

Hope this is able to help someone else in future.

@jackhannah95 @haroldgil Looking at your responses, it appears that the steps you did would be the solution to my issue. On my end, everything works fine; however, when a third-party contractor executes the same scripts I'm using in a SharePoint site, he's getting the error. Before the error, it appears the script is looking at a UNC path where the rmarkdown package is installed rather than a network drive. In addition, I checked the contractor's libPaths() and it appears that it's showing as a UNC path rather than the mapped network drive format.

To confirm your scenarios, did converting the UNC path to a mapped network drive resolve your issues? Also, up to what UNC path subfolder did you map to the network drive? e.g., only up to the user name or up to the actual R subfolder?

jackhannah95 commented 4 years ago

@geopang Yeah converting UNC paths to mapped network drives resolved my issues. They resolved the issues for me alone however - any other user trying to access my scripts on a shared network drive had to convert any UNC paths associated with their account to mapped network drives as well.

I mapped up to username level. It'd probably work at a lower level too but I think mapping the top level drive makes life easier.

rogerjbos commented 4 years ago

I found an easy solution in my case worth sharing. Again the problem seems to stem from the odd representation of a network drive directory. This directory comes into play in the pandoc command because pandoc() seems to indirectly rely on Sys.getenv('R_USER'). image This directory is equivalent to my directory H:/ Thus I created a .Renviron file in H:/ and included in it the single entry R_USER=H:/ I restarted RStudio and the knitting works fine now. Also, looking at the pandoc command, all the weird references to the long/weird representation of H:/ (see image) have been replaced simply with H:/ indicating to me that pandoc() indeed relies on the value of Sys.getenv('R_USER').

I plumbed the depths of Google to find a fix for this problem (on Windows 10) and this was it. My Sys.getenv("R_USER") location was a network drive, as was the (different) location of my R project and the .Rmd file I was trying to knit. My steps to fix were:

  1. Mapped the Sys.getenv("R_USER") location to my H:/ directory (pretty much any letter would've done).
  2. Ran usethis::edit_r_environ() and added R_USER=H:/ to it.
  3. Restarted RStudio.
  4. Re-ran Sys.getenv("R_USER") to ensure it was now H:/.
  5. Mapped the location of my R project to my G:/ directory (again most letters would've done).
  6. Opened the R project from my G:/ directory (either via the shortcut or by typing the path out; both worked for me) instead of the network drive.

Hope this is able to help someone else in future.

This solution worked for me. Thanks @jackhannah95!

gorgitko commented 3 years ago

For those having problems with parallel render() (pandoc: *.html: openFile: does not exist (No such file or directory), see my solution https://github.com/rstudio/rmarkdown/issues/1632#issuecomment-545824711

chrtro1978 commented 3 years ago

This workaround works for Win 10 with network drive. Connect to the network drive using the file browser in Rstudio. Choose any folder. Rstudio now has the necessary permission and everything knits perfectly.

R version 3.6.1 (2019-07-05) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server x64 (build 14393)

Matrix products: default

locale: [1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_3.6.1 htmltools_0.5.0 tools_3.6.1 yaml_2.2.1 rmarkdown_2.2 knitr_1.28 xfun_0.14 digest_0.6.25
[9] rlang_0.4.8 evaluate_0.14

cderv commented 3 years ago

Hi everyone,

Pandoc has made some new fix regarding UNC path on Windows (https://github.com/jgm/pandoc/issues/5127). I wonder if this could be the fix for this issue we have with Pandoc and Rmarkdown.

is someone having the issue able to use Pandoc 2.11 (or above) and try to knit a document ?

Pandoc 2.11+ is shipped with the RStudio 1.4 Preview is one of you is using it. That would be the easiest way to have access to this version as an R user. Otherwise, it is easy to install a release (https://github.com/jgm/pandoc/releases) but you would need to add it to PATH or use rmarkdown::find_pandoc before calling rmarkdown::render

Thank you !

MTF-UMass commented 3 years ago

@cderv I am quite new at this, but I installed pandoc 2.11, used rmarkdown::find_pandoc (found 2.11), called rmarkdown::render, and got the same error, unfortunately. I am using Windows 10.

The above-described workaround of mapping R_USER to a network drive does work.

cderv commented 3 years ago

@MTF-UMass thanks a lot ! That is really good to know - that means unfortunately Pandoc still have the issue. Can you paste the error you get with Pandoc 2.11 to see if anything has changed ?

MTF-UMass commented 3 years ago

@cderv The error I get is: pandoc.exe: \\: openBinaryFile: does not exist (No such file or directory) Error: pandoc document conversion failed with error 1 Execution halted

pandoc is 2.11.2

cderv commented 3 years ago

Can you share the whole pandoc command, which should be printed in the Rmarkdown pane or console ? I would like to see which path fails exactly. Thanks

MTF-UMass commented 3 years ago

@cderv absolutely, sorry about that

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS 03-params.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output 03-params.html --lua-filter "\\umaaffp\users\mtaftferguso\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "\\umaaffp\users\mtaftferguso\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --email-obfuscation none --self-contained --standalone --section-divs --template "\\umaaffp\users\mtaftferguso\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\MTAFTF~1\AppData\Local\Temp\RtmpKomXKh\rmarkdown-str42503354e80.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 
pandoc.exe: \\: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted
cderv commented 3 years ago

Thanks a lot for your help !

eyayaw commented 3 years ago

I am having the same problem on mac.

rmarkdown::render("Analysis/presentation/presentation.Rmd")

#> pandoc: Documentation/references.bib: openBinaryFile: does not exist (No such file or directory)
#> Error: pandoc document conversion failed with error 1

knitr::knit2pdf("Analysis/presentation/presentation.Rmd")
#> Error in tinytex::latexmk(basename(out), engine = compiler, ...) : 
#> The input file 'presentation.md' does not have the .tex extension 
Session info ─ Session info ───────────────────────────────────────────────────────── setting value version R version 4.0.2 (2020-06-22) os macOS 10.16 system x86_64, darwin17.0 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Berlin date 2020-12-16 ─ Packages ───────────────────────────────────────────────────────────── package * version date lib abind 1.4-5 2016-07-21 [1] assertthat 0.2.1 2019-03-21 [1] base64enc 0.1-3 2015-07-28 [1] callr 3.5.1 2020-10-13 [1] class 7.3-17 2020-04-26 [1] classInt 0.4-3 2020-04-07 [1] cli 2.2.0 2020-11-20 [1] clipr 0.7.1 2020-10-08 [1] codetools 0.2-18 2020-11-04 [1] colorspace 2.0-0 2020-11-11 [1] crayon 1.3.4 2017-09-16 [1] crosstalk 1.1.0.1 2020-03-13 [1] DBI 1.1.0 2019-12-15 [1] desc 1.2.0 2018-05-01 [1] devtools 2.3.2 2020-09-18 [1] dichromat 2.0-0 2013-01-24 [1] digest 0.6.27 2020-10-24 [1] dplyr * 1.0.2 2020-08-18 [1] e1071 1.7-4 2020-10-14 [1] ellipsis 0.3.1 2020-05-15 [1] evaluate 0.14 2019-05-28 [1] fansi 0.4.1 2020-01-08 [1] farver 2.0.3 2020-01-16 [1] fs 1.5.0 2020-07-31 [1] generics 0.1.0 2020-10-31 [1] ggplot2 * 3.3.2 2020-06-19 [1] glue 1.4.2 2020-08-27 [1] gtable 0.3.0 2019-03-25 [1] highr 0.8 2019-03-20 [1] hms 0.5.3 2020-01-08 [1] htmltools 0.5.0 2020-06-16 [1] htmlwidgets 1.5.2 2020-10-03 [1] KernSmooth 2.23-18 2020-10-29 [1] knitr 1.30 2020-09-22 [1] labeling 0.4.2 2020-10-20 [1] lattice 0.20-41 2020-04-02 [1] leafem 0.1.3 2020-07-26 [1] leaflet 2.0.3 2019-11-16 [1] leafsync 0.1.0 2019-03-05 [1] lifecycle 0.2.0 2020-03-06 [1] lwgeom 0.2-5 2020-06-12 [1] magrittr 2.0.1 2020-11-17 [1] memoise 1.1.0.9000 2020-08-13 [1] munsell 0.5.0 2018-06-12 [1] pillar 1.4.7 2020-11-20 [1] pkgbuild 1.1.0 2020-07-13 [1] pkgconfig 2.0.3 2019-09-22 [1] pkgload 1.1.0 2020-05-29 [1] png 0.1-7 2013-12-03 [1] prettyunits 1.1.1 2020-01-24 [1] processx 3.4.4 2020-09-03 [1] ps 1.4.0 2020-10-07 [1] purrr 0.3.4 2020-04-17 [1] R6 2.5.0 2020-10-28 [1] raster 3.4-5 2020-11-14 [1] RColorBrewer 1.1-2 2014-12-07 [1] Rcpp 1.0.5.4 2020-11-13 [1] readr * 1.4.0 2020-10-05 [1] remotes 2.2.0 2020-07-21 [1] reprex 0.3.0 2019-05-16 [1] rlang 0.4.9 2020-11-26 [1] rmarkdown 2.6.0001 2020-12-16 [1] rprojroot 2.0.2 2020-11-15 [1] rstudioapi 0.13 2020-11-12 [1] scales 1.1.1 2020-05-11 [1] sessioninfo 1.1.1 2018-11-05 [1] sf * 0.9-6 2020-09-13 [1] sp 1.4-4 2020-10-07 [1] stars 0.4-3 2020-07-08 [1] stringi 1.5.3 2020-09-09 [1] stringr 1.4.0 2019-02-10 [1] testthat 3.0.0 2020-10-31 [1] tibble 3.0.4 2020-10-12 [1] tidyr * 1.1.2 2020-08-27 [1] tidyselect 1.1.0 2020-05-11 [1] tinytex 0.28 2020-12-14 [1] tmap * 3.2 2020-09-15 [1] tmaptools 3.1 2020-07-01 [1] units 0.6-7 2020-06-13 [1] usethis 2.0.0 2020-12-10 [1] vctrs 0.3.5 2020-11-17 [1] viridisLite 0.3.0 2018-02-01 [1] whisker 0.4 2019-08-28 [1] withr 2.3.0 2020-09-22 [1] xfun 0.19 2020-10-30 [1] XML 3.99-0.5 2020-07-23 [1] yaml 2.2.1 2020-02-01 [1] source CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) Github (hadley/memoise@34e8039) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) Github (RcppCore/Rcpp@a72a27c) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) Github (rstudio/rmarkdown@80f14b2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) CRAN (R 4.0.0) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.2) CRAN (R 4.0.0) [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
cderv commented 3 years ago

@Eyayaw I don't think this is the same issue. i.e an issue with network drive as the last and recent comments are showing.

Pandoc will throw this error: openBinaryFile: does not exist (No such file or directory) when a file needed for the rendering is not found - but sometimes it is an indicator of an issue in the source file.

In your case, Pandoc is warning that the bib file referenced in your Rmd document is not found. You should check the bibliography field and the path of the file. Can you confirm that everything is ok on this side ?

Also about knitr:::knit2pdf, I believe this is for Rnw or Rrst document. see ?knit2pdf.

Thank you.

eyayaw commented 3 years ago

@Eyayaw I don't think this is the same issue. i.e an issue with network drive as the last and recent comments are showing.

Pandoc will throw this error: openBinaryFile: does not exist (No such file or directory) when a file needed for the rendering is not found - but sometimes it is an indicator of an issue in the source file.

In your case, Pandoc is warning that the bib file referenced in your Rmd document is not found. You should check the bibliography field and the path of the file. Can you confirm that everything is ok on this side ?

Also about knitr:::knit2pdf, I believe this is for Rnw or Rrst document. see ?knit2pdf.

Thank you.

@cderv Thank you for the quick explanation. Yeah, it works when I copy the 'references.bib' file to the folder where the '.Rmd' file lives. However, I still find it puzzling why rmarkdown/pandoc does not find the Documentation/references.bib file. In fact, I set the Evaluate Chunks in Directory option to Project and I expect that to work. I am missing something here? Thank you.

leonvictorlima commented 3 years ago

Hi,

I am not sure if is the same issue, but when I execute a script in RStudio in Remote Session on Machine Learning Server to create a Rmarkdown (pdf) file I got an error.

=======

Error:

---------------------------------------------------------------- success: FALSE url: http://172.16.13.70:12800/sessions/b7d365b2-f754-4a66-bb80-e02cb905b643/execute method: POST status_code: 500 content: Link: NULL Message: a3bdea4a-2d1f-47c4-a7a6-5ff9b903c924 ExceptionType: NULL ---------------------------------------------------------------- Canceling execution... Error: Execution stopped. In addition: Warning messages: 1: replacing previous import ‘plotly::filter’ by ‘stats::filter’ when loading ‘EMSDashboard’ 2: replacing previous import ‘dplyr::lag’ by ‘stats::lag’ when loading ‘EMSDashboard’ |......................................................................| 100% ordinary text without R code "D:/ProgramFiles/Microsoft/MLServer/PYTHON_SERVER/Scripts/pandoc" +RTS -K512m -RTS Presentation.utf8.md --to beamer --from markdown+autolink_bare_uris+tex_math_single_backslash --output File.tex --variable theme=Frankfurt --highlight-style tango --pdf-engine pdflatex --self-contained --include-in-header defaults.tex --include-in-header beamerthemeEpimed.sty ========== By the way, when the same code is executed inside the Server (server console) this works fine! I noticed some differences in the execution and the Rmarkdown compilation exit, for example: The argument "processing file: File.RMD " is not showed in Local execution. -- Execution from Server -- ================== |..... | 7% ordinary text without R code |.......... | 14% label: unnamed-chunk-1 (with options) List of 1 $ include: logi FALSE |............... | 21% ordinary text without R code |.................... | 29% label: unnamed-chunk-2 (with options) List of 1 $ child: chr "General.Rmd" |....................... | 33% inline R code fragments |............................................... | 67% label: unnamed-chunk-8 |......................................................................| 100% inline R code fragments |......................... | 36% ordinary text without R code |.............................. | 43% label: unnamed-chunk-3 (with options) List of 1 $ child: chr "Admissions.Rmd" .... =========================================== While in Local, we have this "processing file: file.Rmd" being showed.! --- Local --- ======================== processing file: Presentation.Rmd |.... | 7% ordinary text without R code |........ | 14% label: unnamed-chunk-1 (with options) List of 1 $ include: logi FALSE |............ | 21% ordinary text without R code |............... | 29% label: unnamed-chunk-2 (with options) List of 1 $ child: chr "General.Rmd" processing file: ./General.Rmd |.................. | 33% inline R code fragments |.................................... | 67% label: unnamed-chunk-8 ============== Anyone could give me some help in this issue? Tks a Lot!
cderv commented 3 years ago

Hi @leonvictorlima,

I am not sure if is the same issue

it is always preferred to open a new issue that could link to this one instead of commenting in another issue because discussion will always be mixed up.

It would be best to follow if you opened a new issue and use correct formatting at least for code block part. See issue guide: https://yihui.org/issue/

By the way, when the same code is executed inside the Server (server console) this works fine!

It probably means that there is no issue with rmarkdown otherwise it would not work in R console I think.

when I execute a script in RStudio in Remote Session on Machine Learning Server

It could come from something in RStudio IDE or the ML server. Are you using Pro version of those services ? You could ask there support if so to help find the issue.

Anyway, rmarkdown issue board is not the best place for generic question. It is a place for issue found on the package, or feature request for the package. It would be better to ask in place like https://community.rstudio.com if you don't have access to paid support regarding your tools.

Unfortunately, I don't have anything to test and look more into it. And I don't think this is the same issue the one discussed in this GH ticket.

leonvictorlima commented 3 years ago

Hello, @cderv ,

Thank you a lot for your comments. I will check it carefully in order to not mix this one and have a topic specific for it!

In addition, I am gonna ask support for them as well.

I agree with you when say this is not a directly package issue. Maybe it is something in the middle, I mean, among the execution on Server instance and my local. But, I need more tests to confirm it.

Thank you, take care!

jmarshallnz commented 3 years ago

Just chiming in with my experiences with RStudio 1.4+ and pandoc 2.14.1. 2.14.1 has fixed the ".Rmd file located in the user roaming profile (i.e. UNC path) issue", so if RStudio updates to this version of pandoc then that is solved as far as I can tell.

However, there is a related problem: If the .libPaths() is on a roaming profile (UNC) location, and rmarkdown is installed into that location then you get basically the same error, presumably due to pandoc not loading the template files etc correctly. This is supposed to be fixed in pandoc 2.14.1:

https://github.com/jgm/pandoc/commit/26ed7fb4f9e95a00607ab9cfddc48267c717d24b

But it seems that it isn't completely fixed. Am not sure exactly which bit is failing, output is like this:

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS blah.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output blah.html --lua-filter "\\tur-homes2.massey.ac.nz\jcmarsha\My Documents\R\win-library\4.1\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "\\tur-homes2.massey.ac.nz\jcmarsha\My Documents\R\win-library\4.1\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --variable bs3=TRUE --standalone --section-divs --template "\\tur-homes2.massey.ac.nz\jcmarsha\My Documents\R\win-library\4.1\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header "C:\Users\jcmarsha\AppData\Local\Temp\3\Rtmpya8M4d\rmarkdown-strd784b525dcd.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 

In addition, two warnings are generated, suggesting it might be fixable within rmarkdown maybe?

Warning messages:
1: In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\tur-homes2.massey.ac.nz": The specified path is invalid
2: In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\tur-homes2.massey.ac.nz": The specified path is invalid

Everything works fine, and the warnings are not generated if the UNC path is mapped to a drive and then R_LIBS_USER is set accordingly.

kiwifb commented 3 years ago

It seems like windows people have some kind of work around. But non-windows using drive over cifs are not so lucky.

I have seen a similar issue on jupyter because by default they tried to enforce atomic write which didn't work so well on remote file system. It kind of works the first time but after that you have some kind of ghost files preventing things from working. I got the following message from the r markdown window

Error in abs_path(input) : 
  The file 'simulating-the-Roy-Rubin-Model-final.Rmd' does not exist.
Calls: <Anonymous> -> setwd -> dirname -> abs_path
In addition: Warning messages:
1: In file.create(to[okay]) :
  cannot create file 'simulating-the-Roy-Rubin-Model-final.Rmd', reason 'No such file or directory'
2: In normalizePath(path, winslash = winslash, mustWork = mustWork) :
  path[1]="simulating-the-Roy-Rubin-Model-final.Rmd": No such file or directory
Execution halted

when I look at my file system I have

-rwx--x--x 1 frb15 domain users 817988 Jul 28 23:42  simulating-the-Roy-Rubin-Model-final.html*
-????????? ? ?     ?                 ?            ?  simulating-the-Roy-Rubin-Model-final.knit.md
-rwx--x--x 1 frb15 domain users  17041 Jul 28 23:41 'simulating-the-Roy-Rubin-Model final.Rmd'*
-????????? ? ?     ?                 ?            ?  simulating-the-Roy-Rubin-Model-final.Rmd

But I feel one the reason things don't work, is that temporary files are created in place instead of a proper temporary location, /tmp on unix and whatever it would be in windows.