I bought a MacBook Pro with M2 chip, and cannot get many packages to load

A few weeks ago, I bought a new MacBook Pro for work. It is the Apple M2 Max. I transferred everything from my iMac which has an M1 chip. It's interesting that on the iMac, I have none of the problems I'm about to report, which makes me think it's either the chip or the transfer installation. The short version of my problem is that while I have many packages already installed when I installed R on the new computer, I am frequently unable to install any new packages. I've found little to no advice from people at work who know R better than me, and I've gone round and round with GPT-4, so now I'm going to try talking to experts. Here is the version of R I'm running:

platform aarch64-apple-darwin22.4.0
arch aarch64
os darwin22.4.0
system aarch64, darwin22.4.0
status
major 4
minor 3.0
year 2023
month 04
day 21
svn rev 84292
language R
version.string R version 4.3.0 (2023-04-21)
nickname Already Tomorrow

And here is a simple install error I got from trying to install ggplot2.

install.packages("ggplot2", dependences=TRUE)

Installing package into ‘/Users/scott_cunningham/Library/R/arm64/4.3/library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘farver’, ‘isoband’, ‘scales’

  • installing source package ‘farver’ ...
    ** package ‘farver’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    using C++ compiler: ‘Homebrew clang version 16.0.2’
    using C++11
    using SDK: ‘’
    clang++ -std=gnu++11 -I"/opt/homebrew/Cellar/r/4.3.0/lib/R/include" -DNDEBUG -I/opt/homebrew/Cellar/gettext/0.21.1/include -fPIC -g -O2 -c ColorSpace.cpp -o ColorSpace.o
    In file included from ColorSpace.cpp:1:
    In file included from ./ColorSpace.h:4:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/typeinfo:61:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/exception:81:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/__memory/base.h:14:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/__debug:14:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/iosfwd:95:
    /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
    #include_next <wchar.h>
    ^~~~~~~~~
    1 error generated.
    make: *** [/opt/homebrew/Cellar/r/4.3.0/lib/R/etc/Makeconf:198: ColorSpace.o] Error 1
    ERROR: compilation failed for package ‘farver’
  • removing ‘/Users/scott_cunningham/Library/R/arm64/4.3/library/farver’
    Warning in install.packages :
    installation of package ‘farver’ had non-zero exit status
  • installing source package ‘isoband’ ...
    ** package ‘isoband’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    using C++ compiler: ‘Homebrew clang version 16.0.2’
    using C++11
    using SDK: ‘’
    clang++ -std=gnu++11 -I"/opt/homebrew/Cellar/r/4.3.0/lib/R/include" -DNDEBUG -I/opt/homebrew/Cellar/gettext/0.21.1/include -fPIC -g -O2 -c clip-lines.cpp -o clip-lines.o
    In file included from clip-lines.cpp:3:
    In file included from /opt/homebrew/Cellar/r/4.3.0/lib/R/include/R.h:39:
    In file included from /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/cstdlib:85:
    /Users/scott_cunningham/opt/anaconda3/bin/../include/c++/v1/stdlib.h:93:15: fatal error: 'stdlib.h' file not found
    #include_next <stdlib.h>
    ^~~~~~~~~~
    1 error generated.
    make: *** [/opt/homebrew/Cellar/r/4.3.0/lib/R/etc/Makeconf:198: clip-lines.o] Error 1
    ERROR: compilation failed for package ‘isoband’
  • removing ‘/Users/scott_cunningham/Library/R/arm64/4.3/library/isoband’
    Warning in install.packages :
    installation of package ‘isoband’ had non-zero exit status
    ERROR: dependency ‘farver’ is not available for package ‘scales’
  • removing ‘/Users/scott_cunningham/Library/R/arm64/4.3/library/scales’
    Warning in install.packages :
    installation of package ‘scales’ had non-zero exit status
    ERROR: dependencies ‘isoband’, ‘scales’ are not available for package ‘ggplot2’
  • removing ‘/Users/scott_cunningham/Library/R/arm64/4.3/library/ggplot2’
    Warning in install.packages :
    installation of package ‘ggplot2’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/9d/_2mr739j3sz0szn1f4fsypss5n8_l0/T/RtmpGzRmDW/downloaded_packages’

I was hoping someone might have some ideas? I'm really frustrated and lost.

Given that the update to R 4.3.0 happened at about the same time as the switch to the new computer, I suspect that there are issues using homebrew and anaconda with the new version of R. The impression I get from the R for macOS Developers page is that it is best to stick with Xcode command line tools and the universal GNU Fortran compiler. I followed the instructions on the site's Tools page. Installation was very easy and compiling packages on macOS has never been this smooth. Then again, I have zero experience with homebrew and anaconda with R, so your problem may be something completely different.

I did have problems with homebrew, so let me try this and get back to you. Thank you EconProf!

I forgot that this is the second problem I repeatedly run into -- on numerous occasions, in trouble shooting this, this is the error message I will get with other recommendations. Here I am trying to install the universal GNU compiler. I've attached that error message. I can't quite figure out how these problems are related but it seems like they're all related?

Edit: I'm going down more rabbit holes. Can't seem to login to Safe mode on my Mac no matter what I try. Not sure how exactly to proceed, but will update if I find something. Just not sure if there's some obvious issue or not.

I checked on CRAN and the latest version of isoband has been available as a compiled arm64 binary for R 4.3 since April 11, 2023. Same for farver and scales. I wonder why your Mac is trying, and failing, to compile from source instead.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.