R markdown won't knit, gives fatal error creating temp file?

Hi all, I tried posting on Stack Overflow but no one seems to know how to resolve this. I've seen this Q a few times and no answers ever logged. Please help!

I can't seem to knit any markdown Rmd files to html or pdf. This happened all of a sudden and on Rmds I've used successfully for years. I tried downloading from repos, and the same problem exists. It seems to be on my computer but not on colleagues that download repos, so very strange. I updated yaml, rmarkdown, knitr packges, reinstalled new versions of Rstudio, R and still no solution.

When I try to knit, I get a prompt saying "Install Required Package: Rendering R Markdown documents requires and updated version of the rmarkdown pakage. Install now?". If I click no, everything halts. If I click yes, I get the following error immediately:

Fatal error: creating temporary file for '-e' failed

I have rmarkdown package v. 1.1 installed, and I uninstalled and reinstalled it, yet I still get this prompt. No clue what's happening or why this would start out of nowhere. I tried pulling from repo and running on a new computer and it will knit so it seems like it isn't in what is coded, but perhaps something loaded/not...? At a loss

Thank you for any help!

Hi, and welcome.

The current version of rmarkdown is 1.16, so the first thing is to figure out why your setup is refusing to be well behaved.

It would help to know what platform you're using. The error sounds like a permissions problem. If you're on Windows, I may not be able to help, since I've pretty much been away since the mid-90s.

Can you open an R session and


and report back, please.

Using a Mac and Rstudio

Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] rmarkdown_1.16    plyr_1.8.4        DescTools_0.99.29 rcompanion_2.3.7  car_3.0-4        
 [6] carData_3.0-2     dplyr_0.8.3       FSA_0.8.25        devtools_2.2.1    usethis_1.5.1    
[11] survminer_0.4.6   ggpubr_0.2.3      magrittr_1.5      broom_0.5.2       cowplot_1.0.0    
[16] rms_5.1-3.1       SparseM_1.77      Hmisc_4.2-0       Formula_1.2-3     survival_2.44-1.1
[21] lattice_0.20-38   polspline_1.1.16  gridExtra_2.3     ggfortify_0.4.7   plotrix_3.7-6    
[26] forcats_0.4.0     stringr_1.4.0     purrr_0.3.3       readr_1.3.1       tidyr_1.0.0      
[31] tibble_2.1.3      ggplot2_3.2.1     tidyverse_1.2.1   pacman_0.5.1      emmeans_1.4.2    

loaded via a namespace (and not attached):
  [1] readxl_1.3.1        backports_1.1.5     lazyeval_0.2.2      splines_3.6.1       TH.data_1.0-10     
  [6] digest_0.6.22       htmltools_0.4.0     checkmate_1.9.4     memoise_1.1.0       cluster_2.1.0      
 [11] openxlsx_4.1.2      remotes_2.1.0       modelr_0.1.5        matrixStats_0.55.0  sandwich_2.5-1     
 [16] prettyunits_1.0.2   colorspace_1.4-1    rvest_0.3.4         haven_2.1.1         xfun_0.10          
 [21] libcoin_1.0-5       callr_3.3.2         crayon_1.3.4        jsonlite_1.6        zeallot_0.1.0      
 [26] zoo_1.8-6           glue_1.3.1          gtable_0.3.0        MatrixModels_0.4-1  pkgbuild_1.0.6     
 [31] dunn.test_1.3.5     abind_1.4-5         scales_1.0.0        mvtnorm_1.0-11      Rcpp_1.0.2         
 [36] xtable_1.8-4        htmlTable_1.13.2    foreign_0.8-71      km.ci_0.5-2         stats4_3.6.1       
 [41] htmlwidgets_1.5.1   httr_1.4.1          RColorBrewer_1.1-2  modeltools_0.2-22   acepack_1.4.1      
 [46] ellipsis_0.3.0      pkgconfig_2.0.3     nnet_7.3-12         multcompView_0.1-7  tidyselect_0.2.5   
 [51] labeling_0.3        rlang_0.4.1         munsell_0.5.0       cellranger_1.1.0    tools_3.6.1        
 [56] cli_1.1.0           generics_0.0.2      evaluate_0.14       EMT_1.1             yaml_2.2.0         
 [61] processx_3.4.1      knitr_1.25          fs_1.3.1            zip_2.0.4           survMisc_0.5.5     
 [66] coin_1.3-1          nlme_3.1-140        quantreg_5.51       xml2_1.2.2          compiler_3.6.1     
 [71] rstudioapi_0.10     curl_4.2            testthat_2.2.1      ggsignif_0.6.0      stringi_1.4.3      
 [76] ps_1.3.0            desc_1.2.0          Matrix_1.2-17       KMsurv_0.1-5        vctrs_0.2.0        
 [81] pillar_1.4.2        lifecycle_0.1.0     lmtest_0.9-37       estimability_1.3    data.table_1.12.6  
 [86] R6_2.4.0            latticeExtra_0.6-28 rio_0.5.16          sessioninfo_1.1.1   codetools_0.2-16   
 [91] boot_1.3-22         MASS_7.3-51.4       assertthat_0.2.1    pkgload_1.0.2       rprojroot_1.3-2    
 [96] nortest_1.0-4       withr_2.1.2         multcomp_1.4-10     parallel_3.6.1      expm_0.999-4       
[101] hms_0.5.1           grid_3.6.1          rpart_4.1-15        lubridate_1.7.4     base64enc_0.1-3
1 Like

Thanks. So we're both on Mojave and we both have rmarkdown 1.16, but I can knit and you can't.

Are we on the same version of pandoc?

 $ 502:  pandoc -v
pandoc 2.7.3

So I don't have pandoc loaded. I added


and I get

Warning in install.packages :
  package ‘pandoc’ is not available (for R version 3.6.1)

I'm not sure if you were suggesting to load pandoc or if this is something that I should have loaded or not. Like I mentioned, things worked and then they didn't, and this was before I updated by R and R studio.

I went to the following link and downloaded pandoc for MacOS (Pandoc - Installing pandoc), shutdown R and reopened, but same error.

Sorry to have been unclear; pandoc is not, indeed, a package, but an external dependency. BTW: It's the Swiss Army Knife™️ of document conversion.

Next step is to see if it's in your PATH environment, I guess.

which pandoc
pandoc -v

My reasoning is that if rmarkdown can't find pandoc that would be a simple explanation of the problem.

Thanks technocrat--When I enter that code in the terminal I get

pandoc -v
pandoc 2.7.3
Compiled with pandoc-types, texmath, skylighting 0.8.1

Getting closer; this shows pandoc is in your system $PATH. Now, my guess is that it's a permission issue, but where?

Does your ~/.REnviron file have anything in addition to

 $ 501:  cat .Renviron

This is a bit new to me in terminal, but if I enter 'cat .Renviron' in terminal it returns

TMPDIR = C:/Rtmp

but nothing else. Is there something I'm missing?

1 Like

That look's suspiciously like it's there because of a setup using windows; and I seriously doubt that you have a directory of that name on Mojave!

Let's try getting rid of it. If that works, great! Then it wouldn't hurt to copy in the other lines.

cp .Renviron .Renviron.hold

then edit .Renviron using a plain text editor to remove that line.

The idea is that you can't write to a directory that doesn't exist. In the cases where it's a real directory, but you don't have write permissions, it would also give the same error you're experiencing.

Sorry @technocrat, you lost me. I can enter in command line

cp .Renviron .Renviron.hold

it takes the command, but I don't see how I'm supposed to edit the .Renvironment or where this is. I have no idea why this would have changed or how it would have been modified all of a sudden to give me this issue. Can you provide some more info on how I could make the changes you are suggesting?

.Renviron is in your home directory and can be edited by any plain text editor, such as vim in the command line or by TextEdit in the gui.

Actually, though, just go ahead and

rm .Renviron

I just tested that on my Mojave and it didn't affect RStudio or R. So, try that and report back?

1 Like

HOLY CRAP IT WORKED! Thank you so much, I can now knit the .Rmd files.

1 Like

Great. Please mark as a solution to help future pilgrims. (AFAIK no one here has ever bragged about numbers of solutions, so it ain't about me.) Glad you're back in operation!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.