A warning message
In has_crop_tools() :
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
appears when a simple R Markdown document is knitted to PDF:
---
output: pdf_document
---
![foo](bar.png)
The bar.png
image is embedded into PDF all right, but it looks like there is a spelling error in called ghostcript
command (shouldn't it be ghostscript after the name of Ghostscript interpreter?). How to properly address this warning message?
My xfun::session_info()
output:
R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042), RStudio 1.4.1103
Locale:
LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
LC_NUMERIC=C LC_TIME=English_United States.1252
Package version:
base64enc_0.1.3 compiler_4.0.4 digest_0.6.27 evaluate_0.14 glue_1.4.2 graphics_4.0.4 grDevices_4.0.4
highr_0.8 htmltools_0.5.0 jsonlite_1.7.1 knitr_1.31 magrittr_2.0.1 markdown_1.1 methods_4.0.4
mime_0.9 rlang_0.4.10 rmarkdown_2.7 stats_4.0.4 stringi_1.5.3 stringr_1.4.0 tinytex_0.27
tools_4.0.4 utils_4.0.4 xfun_0.19 yaml_2.2.1
You need to tell R where to find ghostscript. For Windows, download ghostscript from http://ghostscript.com/download/gsdnld.html After installing ghostscript, we still need to tell R where to find ghostscript. To do so, it is necessary to set adapt your system’s Path variable: Go to Control Panel → System and Security → System → Advanced System Settings → computer name, domain and workgroup settings → Advanced → Environment Variables Find the Path variable within System Variables, select it and click on edit. Add C:\Program Files\gs\gs9.23\bin (or the directory where you installed ghostscript to) to the Path variable. In Windows 10, you can do this by clicking on New and entering the path. In other Windows versions, just append the path to the variable value, seperated by a semicolon. Restart R For MacOS, download and install the Ghostscript 9.23 package from http://pages.uoregon.edu/koch/ Restart R
I found the solution from this website https://rnbeads.org/data/installing_rnbeads.html
I followed Hana's suggested solution to the letter (including a restart) and my R session still could not find ghostscript. I had to include this line of code in my script for it to work:
Sys.setenv(R_GSCMD = "C:/Program Files/gs/gs9.54.0/bin/gswin64c.exe")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With