Repository navigation
Open
Labels
Description
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
Reacted by NilsOle, Chris Chapman, Rasmus Hertzum, Jan Vlug and awsms
Activity
yihui commentedon Feb 24, 2018
harryprince commentedon Feb 26, 2018
yihui commentedon Feb 26, 2018
ADraginda commentedon Feb 27, 2018
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 commentedon Feb 27, 2018
@ADraginda Are you also on Shiny Server? Is it reproducible locally?
NilsOle commentedon Jun 4, 2018
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
reproducemarkdownerror:hello(3)for 3 cores respectively. This should give you error messages.reproducemarkdownerror:hello(1)should not give you any errors.reproducermarkdownerror_0.1.0.tar.gz
Output (operation produces only 92 files although 100 expected):
Script taken from here:
https://gist.github.com/hrbrmstr/17bc21af55392f23f012f57bb2fda51c
Version information:
goldingn commentedon Aug 24, 2018
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
This works
This doesn't:
AndrewManHayChiu commentedon Nov 21, 2018
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 commentedon May 24, 2019
vthivierge commentedon Jul 18, 2019
vthivierge commentedon Jul 18, 2019
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 commentedon Jul 22, 2019
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
Network drive
Local C:\ drive
Session Info
RStudio Version
39 remaining items
jmarshallnz commentedon Jul 28, 2021
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:
jgm/pandoc@26ed7fb
But it seems that it isn't completely fixed. Am not sure exactly which bit is failing, output is like this:
In addition, two warnings are generated, suggesting it might be fixable within rmarkdown maybe?
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 commentedon Jul 29, 2021
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
when I look at my file system I have
But I feel one the reason things don't work, is that temporary files are created in place instead of a proper temporary location,
/tmpon unix and whatever it would be in windows.cderv commentedon Jul 29, 2021
@jmarshallnz @kiwifb Thanks a lot that is very helpful ! With your comment, I believe we have something to reproduce. It require to setup an environment with UNC path, so it won't be straightforward for me.
Also, we still don't know for sure if this is Pandoc or rmarkdown. It is probably both.
@jabranham the commit you linked to (jgm/pandoc@26ed7fb) is in a release version since Pandoc 2.11. When you say
Do you have another fix in Pandoc in mind ? FWIW, next RStudio IDE version should be shipped with 2.14.1
@kiwifb The error you get is clearly not from Pandoc and it different. If you can reproduce, can you share also the
traceback()after the error ? Whatabs_path()does is callingfile.exists(). With rmarkdown, everything happens by default relatively to the input path, included intermediates. I believe mainly because those intermediates needs to be found by Pandoc and we would need to deal with absolute path everywhere including in the generated md file. Note that some resources are created in a tmp folder like special HTML headers to include.We'll try to make quicker progress with your information, thanks for sharing ! We definitely need to reproduce this in order to better dig into the issue with file managements and computation with network drive.
Thanks again
jmarshallnz commentedon Jul 29, 2021
@cderv Yes, you're right about that commit being in 2.11. Strange. There definitely is a difference in behaviour between pandoc 2.11 and 2.14.1 with RStudio 1.4. With v2.11 I can reproduce (everytime) the fault where the .Rmd is stored in a UNC path it fails to build. With 2.14.1 this is gone, except for the case where rmarkdown is also installed on a UNC path.
I can't really see anything obvious in pandoc other than that commit, so not sure what fixed (part of) the problem.
cderv commentedon Jul 29, 2021
Then it is possible that something in RStudio IDE helped fix this issue. There was also non-pandoc issue with RStudio IDE and UNC path I believe.
With what you say, it could mean that next version of RStudio IDE with Pandoc 2.14.1 should be better.
We would need to look then more at the issue with rmarkdown package on network drive. For this, I am thinking we may need to copy the resources included into the package locally so that Pandoc does not need to access them through network drive (if that is the issue). Currently, some resource are passed to pandoc using absolute path to rmarkdown installation folder.
kiwifb commentedon Jul 29, 2021
My setup is a rstudio server running on ubuntu 20.04 with some remote folders mounted via cifs. The previous error I think had some extra layers of indirections because the filename had space in it, which lead to extra normalization.
The first time it knits OK
But the second time (or sometimes more time, it is a bit finicky) I now get
I am doing everything from the rstudio interface at the moment, how do I run things to get to the backtrace you want. I can run R directly from the command line if needed.
kiwifb commentedon Jul 29, 2021
Figured it out by running
rmarkdown::renderfrom rstudio's console.cderv commentedon Jul 29, 2021
That is a bit disturbing to me that this is sometimes working, and sometimes not.
Thanks for sharing the setup. I'll see if I can get my hand of such configuration.
kiwifb commentedon Jul 29, 2021
I think there is a lot to be done around some remote file system. What personally gets my attention as a programer in other language and context is that the intermediary file (in
.knit.md) shouldn't be created there. It is transient and disappear once you are done. On most OS there are special place for those in/tmp(or windows equivalent) or~/.cacheor other special folders if you are more sophisticated. There is no absolute guarantee of locality but it is way cleaner than leaving your stuff next to your input and output - unless you are debugging.cderv commentedon Jul 29, 2021
I understand you point, and I think what you describe applies to more standard temporary content. However, for the specific usage here, we need to consider the way Pandoc is working. For example, it is highly possible that
.knit.mdwill contain references to resource relatively to your Rmd document. If the resulting md file is elsewhere, those resources linked in the md doc won't be located relatively to the source file anymore and Pandoc won't find them during the conversion to HTML. Some processing would need to happen to handle absolute vs relative path correctly. That is just an example. Also, rmarkdown does write totempdir()already some files that does not have this type of concerns.We are a bit off topic here. You can open a new issue if you want to discuss some ways to improve that (Knitr + Pandoc + LaTeX interaction needs to be considered here). Thanks !
kiwifb commentedon Jul 29, 2021
Ha, it just proves that I am completely ignorant of the context and that I don't know what I am talking about. I have been spending a few hours looking at the code earlier today and I couldn't really untangle the various abstractions. R is not the language I am the most familiar with.
I have come to that conversation because I am supporting a lecturer for whom I have organised the particular setup. The cifs mount is to access our university shared file system for convenience. As it turns out it is not currently convenient to run a number of things including knitting directly on it :)
cderv commentedon Jul 29, 2021
Thanks for chiming in then !
We really appreciate having also external contributors with different background to share views and thoughts on the ecosystem because it brings new perspective. If you still want to look deeper with your setup (and I think that would us), you could try without R and rmarkdown, using directly Pandoc to convert a document with different scenarios. For example :
If this does not work well at this level, then it is why we have a hard time looking at it from our level 🤔
EPriske commentedon Oct 5, 2021
This solved my problem with R Markdown. Thank you so much
abhiavi commentedon Mar 30, 2026
I'd like to help resolve this file handling error. Could you please confirm the repository's contribution policy and the preferred process for submitting a fix?
yihui commentedon Aug 25, 2026
For those hitting this specifically when running
rmarkdown::render()in parallel (e.g.registerDoParallel(cores > 1),foreach %dopar%, or a fork cluster) — as reported by @NilsOle and others above — this was the same root cause as #1632: forked workers sharetempdir(), and each render's cleanup deleted sibling renders' temp files mid-conversion. Fixed in #2631 — please try the dev version:Note this does not address the other cause discussed in this thread —
.Rmdfiles or R installed on a network/UNC drive on Windows (theSys.getenv('R_USER')/.libPaths()reports). That's a separate issue and remains open.