Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stdio.h not found during r package installation

Tags:

r

I have been having some difficulties with my R install. I realised that I was unable to install packages and thought that it was due to having been tinkering with the packages I had installed recently. As I am a novice I thought that a clean install might fix it so I uninstalled R and Rstudio (via homebrew).

On reinstall I'm faced with the same issue. This is part of the console output from

install.packages("tidyverse")

/usr/local/opt/llvm/bin/clang -fopenmp -I"/usr/local/Cellar/r/3.5.1/lib/R/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include   -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c assumptions.c -o assumptions.o
In file included from assumptions.c:21:
/usr/local/Cellar/r/3.5.1/lib/R/include/Rinternals.h:39:11: fatal error: 'stdio.h' file not found
# include <stdio.h>
      ^~~~~~~~~
1 error generated.

Searching this site and others suggested that this is to do with lacking the Xcode command line tools. I have checked that these are installed.

Searching for stdio.h in terminal shows numerous versions in the various subfolders (tvos, iOS etc.)

other missing files include: stdlib.h, assert.h and unistd.h

I can provide the full output if that would help

like image 235
hisspott Avatar asked Oct 08 '18 12:10

hisspott


People also ask

Why is my RStudio not installing packages?

Make sure that the package is available through CRAN or another repository, that you're spelling the name of the package correctly, and that it's available for the version of R you are running.

How do I manually install an R package?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.

Why I Cannot install package in R?

Changing the configuration in R Studio to solve install packages issue. Go To Tools -> Global option -> Packages. Then uncheck the option “Use secure download method for HTTP”. For other RStudio issues refer to official Troubleshooting Guide here.


1 Answers

Further searches have identified that in Xcode 10 (as is bundled with macOS Mojave), the location of the standard path for stdio.h and other utilities has moved.

"Legacy software" that looks for the macOS headers in the base system under /usr/include will not find the required files.

To patch this, Xcode includes a package to create links for such software to find the files.

For Xcode 10 the package file is located at:

/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

This information was sourced from the apple Developer forums

After installing this package and restarting the computer I have successfully installed the tidyverse.

I did run into another issue where my C compiler was not able to create executables but this was solved in this thread.

like image 161
hisspott Avatar answered Sep 17 '22 18:09

hisspott