Trying to knit to PDF (RStudio Newbie)

Hi there!
I'm running RStudio 1.2.5033 on macOS 10.15.2

When trying to knit my Markdown to PDF I get the following error:

processing file: Auswertung-Sonnencremebewertung.Rmd
Fehler in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called 'stringi'
Ruft auf: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Ausführung angehalten

From that I tried to install "stringi" (install.packages("stringi", type = "source")) but when I'm trying to do that, I get an error as well:

  • installing source package ‘stringi’ ...
    ** Paket ‘stringi’ erfolgreich entpackt und MD5 Summen überprüft
    ** using staged installation
    checking for R_HOME... /Library/Frameworks/R.framework/Resources
    checking for R... /Library/Frameworks/R.framework/Resources/bin/R
    checking for endianness... little
    checking for R >= 3.1.0 for C++11 use... yes
    checking for R < 3.4.0 for CXX1X flag use... no
    checking for cat... /bin/cat
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    checking for local ICUDT_DIR... icu61/data
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in /private/var/folders/_2/lj5nx2_s317gkvp2lsr02sch0000gq/T/RtmpF0oKpA/R.INSTALL7ef132e63ccc/stringi': configure: error: C compiler cannot create executables See config.log' for more details
    ERROR: configuration failed for package ‘stringi’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/stringi’
    Warning in install.packages :
    installation of package ‘stringi’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/_2/lj5nx2_s317gkvp2lsr02sch0000gq/T/RtmpJ8jRvE/downloaded_packages’

I already searched for some solutions and found this:
xcode-select --install
but I end up with:
error: xcode not found
even though I have installed Xcode.

I couldn't find any solution to my problem after doing quite some research, so I decided to post it here.
I'm very thankful for any help!

Hi @leafyus,

Where did you run the xcode-select --install command? This needs to be run from the terminal/shell so that your computer will install the xcode tools. Run this in the terminal, not the R console. Once the xcode tools are installed, restart R/RStudio and try to re-install stringi again. If it can now properly compile/install the package, then that will put you one step closer to rendering your Rmd document.

Do you have a TeX distribution installed?

2 Likes

You don’t have to install from source. stringi and other major packages come precompiled for OS, usually just a few weeks or less after new releases that need compiling. My experience has been that if it doesn’t install from source the first time, you have to edit the source code, which is not time well spent

Thank you very much for the quick answer!
I ran the command from the terminal and then installed stringi again. After the installation was complete, I tried to knit to PDF again, but got another error.

Luckily a solution to that new error was already posted somewhere and now everything works!

3 Likes

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