Newbie can't knit to pdf

rstudio

#1

Lately I am unable to knit to pdf - not sure what happened to create this problem. tinytex is installed and worked fine for a while. Whenever I attempt to knit to pdf I get a message like the following. (Here I was attempting to knit the demo knit-to-pdf file supplied by Rstudio when one creates a new R Markdown document.)

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS Untitled.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output Untitled.tex --template /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes' 
output file: Untitled.knit.md

Error: Failed to compile Untitled.tex.
Execution halted
sh: rm: command not found

When I knit to anything, the last line of the message (from rmarkdown?) is always
sh: rm: command not found

Here is the session info, in case that is any help

sessionInfo
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X Mavericks 10.9.5

locale:
[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] devtools_1.13.6

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18    digest_0.6.12   withr_2.1.2     rprojroot_1.2   R6_2.2.2       
 [6] backports_1.1.0 git2r_0.21.0    magrittr_1.5    evaluate_0.10.1 httr_1.3.1     
[11] stringi_1.2.4   curl_2.8.1      tools_3.3.3     stringr_1.3.1   yaml_2.2.0     
[16] memoise_1.1.0   htmltools_0.3.6 knitr_1.20     
> library("tinytex", lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resources/library")
> session_info()
Session info ----------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.3 (2017-03-06)
 system   x86_64, darwin13.4.0        
 ui       RStudio (1.1.456)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       Pacific/Honolulu            
 date     2018-10-02                  

Packages --------------------------------------------------------------------------------------
 package   * version date       source                        
 backports   1.1.0   2017-05-22 CRAN (R 3.3.2)                
 base      * 3.3.3   2017-03-07 local                         
 curl        2.8.1   2017-07-21 CRAN (R 3.3.2)                
 datasets  * 3.3.3   2017-03-07 local                         
 devtools  * 1.13.6  2018-06-27 CRAN (R 3.3.3)                
 digest      0.6.12  2017-01-27 CRAN (R 3.3.2)                
 evaluate    0.10.1  2017-06-24 CRAN (R 3.3.2)                
 git2r       0.21.0  2018-01-04 CRAN (R 3.3.2)                
 graphics  * 3.3.3   2017-03-07 local                         
 grDevices * 3.3.3   2017-03-07 local                         
 htmltools   0.3.6   2017-04-28 CRAN (R 3.3.2)                
 httr        1.3.1   2017-08-20 CRAN (R 3.3.2)                
 knitr       1.20    2018-02-20 CRAN (R 3.3.3)                
 magrittr    1.5     2014-11-22 CRAN (R 3.3.0)                
 memoise     1.1.0   2017-04-21 CRAN (R 3.3.2)                
 methods   * 3.3.3   2017-03-07 local                         
 R6          2.2.2   2017-06-17 CRAN (R 3.3.2)                
 Rcpp        0.12.18 2018-07-23 CRAN (R 3.3.3)                
 rmarkdown   1.10    2018-06-11 CRAN (R 3.3.3)                
 rprojroot   1.2     2017-01-16 CRAN (R 3.3.2)                
 stats     * 3.3.3   2017-03-07 local                         
 stringi     1.2.4   2018-07-20 CRAN (R 3.3.3)                
 stringr     1.3.1   2018-05-10 CRAN (R 3.3.3)                
 tinytex   * 0.8.2   2018-10-02 Github (yihui/tinytex@1b130e1)
 tools       3.3.3   2017-03-07 local                         
 utils     * 3.3.3   2017-03-07 local                         
 withr       2.1.2   2018-03-15 CRAN (R 3.3.3)                
 xfun        0.3     2018-07-06 CRAN (R 3.3.3)                
 yaml        2.2.0   2018-07-25 CRAN (R 3.3.3)

#2

Maybe you need to set the PATH



#3

Sys.getenv("PATH")

[1] "/Applications/Octave.app/Contents/Resources/usr/bin: /usr/bin :/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/opt/local/bin”

Apparently uname is in /usr/bin, and /usr/bin is in the path.

I wondered if /Applications/Octave.app/Contents/Resources/usr/bin might be causing trouble, so I removed it...

Sys.setenv(PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/opt/local/bin”)

...but that didn’t help either.

The error message always concludes with…

sh: rm: command not found

which doesn’t make a lot of sense to me because rm is also in the path (see above)...

$ which rm

/bin/rm

I also tried recreating the rstudio-desktop file…

$ mv ~/.rstudio-desktop ~/backup-rstudio-desktop

…but that didn’t help either.