Can't install most packages on Mac

I re-imaged my computer running and now I can't install most packages. My environment looks like

macOS Mojave 10.14.1
/Library/Developer/CommandLineTools # xcode-select -p
XQuartz 2.7.11
Microsoft R Open Feather Spray 3.5.1
clang version 6.0.0
GNU Fortran (Homebrew GCC 8.2.0) 8.2.0 # I have 6.1 in /usr/local/gfortran

If I try to install stringi

> install.packages('stringi')
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/stringi_1.2.4.tar.gz'
Content type 'application/octet-stream' length 17916239 bytes (17.1 MB)
==================================================
downloaded 17.1 MB

* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
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
checking for local ICUDT_DIR... icu61/data
checking for gcc... /usr/local/clang4/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/private/var/folders/xh/jc23m_j970b6nkz4g2sgc6f80000gn/T/RtmpbefCuf/R.INSTALL141ea388f7f07/stringi':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘stringi’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/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/xh/jc23m_j970b6nkz4g2sgc6f80000gn/T/RtmpuruBlu/downloaded_packages’

If I try to install data.table

> install.packages('data.table')
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/src/contrib/data.table_1.11.4.tar.gz'
Content type 'application/octet-stream' length 3284613 bytes (3.1 MB)
==================================================
downloaded 3.1 MB

* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** libs
/usr/local/clang4/bin/clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include  -fopenmp -fPIC  -DU_STATIC_IMPLEMENTATION -Wall -mtune=core2 -g -O2 -I/opt/X11/include  -c assign.c -o assign.o
In file included from assign.c:1:
In file included from ./data.table.h:1:
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5.1-MRO/Resources/library/data.table’
Warning in install.packages :
  installation of package ‘data.table’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/xh/jc23m_j970b6nkz4g2sgc6f80000gn/T/RtmpuruBlu/downloaded_packages’

Any guides updated to the latest Mac OS?

After upgrading to Mojave myself, and seeing a couple issues, I've determined two things you generally need to do to get up and running again. Both at the command line:

  1. xcode-select --install
  2. Run installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / which has been related to a number of strange issues (including one with rcpp autocomplete and with xml2)

You may need to use sudo with the second command.

This stack overflow post provides a lot more detail about the missing stdlib.h header, but the second suggestion I've given here seemed to be the solution there too.

6 Likes

Would any of y'all know how to finish up the set up with respect to gfortran?

make: /usr/local/gfortran: Permission denied
make: *** [eigen.o] Error 1

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