Sverre
Sverre

Reputation: 757

Compile R packages from source (Mac OS X)

I'm running Mac OS X 10.7.5 (Lion), which means that the latest version of R I can run is 3.2.1. Since binaries of packages are no longer being made for this version, it means that I need to install the latest package versions from source. I can do this with

install.packages(pkgs, type = "source")

I installed GNU Fortran, although it's not clear to me whether I need it or not in order to compile R packages.

When I try to compile packages from source in R, however, I get error messages indicating that I don't have (or that R cannot find) the necessary compiling tools. Cf. e.g.:

* installing *source* package ‘scales’ ...
** package ‘scales’ successfully unpacked and MD5 sums checked
** libs
sh: make: command not found
ERROR: compilation failed for package ‘scales’

and

* installing *source* package ‘stringi’ ...
** package ‘stringi’ successfully unpacked and MD5 sums checked
checking for local ICUDT_DIR... icu55/data
checking for R_HOME... /Library/Frameworks/R.framework/Resources
checking for R... /Library/Frameworks/R.framework/Resources/bin/R
checking for R >= 3.1.0 for C++11 use... yes
checking for R < 3.4.0 for CXX1X flag use... yes
checking for cat... /bin/cat
/Library/Frameworks/R.framework/Resources/bin/config: line 150: make: command not found

[...]

checking for gcc... no
checking for cc... no
checking for cl.exe... no
/Library/Frameworks/R.framework/Resources/bin/config: line 153: make: command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 269: make: command not found
configure: error: in `/private/var/folders/2r/6c5vhb4s3zx3zs4d1dbf9p940000gn/T/Rtmpob4pMm/R.INSTALLd4676ad8595/stringi':
configure: error: no acceptable C compiler found in $PATH

I assume what's needed is to install the necessary compiling tools for R packages. What do I need to do?

(If I need to provide additional information, just ask for it in a comment, and I will provide it)

Upvotes: 0

Views: 2211

Answers (1)

Oo.oO
Oo.oO

Reputation: 13375

It might be tricky. First of all, double check whether you can download XCode from AppStore or not. If you can, you will be able to install command line tools as well. Either via Preferences -> Downloads (as far as I recall), or they will be installed during first startup.

Alternatively, create free account here:

http://developer.apple.com

Then, head to:

https://developer.apple.com/download/more/

and find XCode. It might be you will need to install some really old version.

As @hrbrmstr mentioned, it might be that installing virtual machine (e.g. inside VirtualBox) with Linux will be less painful.

Note that you will probably encounter more and more issues while installing packages. There is no easy way if you are forced to stick with old OS X :(

Update:

As @Sverre pointed out, it would be better to have a complete list of links here:

XCode - (Lion version) download from Apple (not to confuse with AppStore)

Command Line Tools - (Lion version) you can install them separately, without installing XCode

Upvotes: 1

Related Questions