I'm pretty new to R, but I've used it a little bit. However, I'm running into a problem and can't figure it out, despite having read through over a dozen other resources. For reasons I won't get into, I had to update R and R Studio. However, now none of my packages will install. For example, when I try to install dplyr
, this is what I get:
> install.packages("dplyr")
There is a binary version available but the source version is later:
binary source needs_compilation
dplyr 1.0.10 1.1.0 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘dplyr’
trying URL 'https://cran.rstudio.com/src/contrib/dplyr_1.1.0.tar.gz'
Content type 'application/x-gzip' length 1068347 bytes (1.0 MB)
==================================================
downloaded 1.0 MB
* installing *source* package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/Cellar/gcc/9.2.0/bin/g++-7 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c chop.cpp -o chop.o
/bin/sh: /usr/local/Cellar/gcc/9.2.0/bin/g++-7: No such file or directory
make: *** [chop.o] Error 127
ERROR: compilation failed for package ‘dplyr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr’
Warning in install.packages :
installation of package ‘dplyr’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/k7/pbrcjpr517x06fhvnkvbq0nc0000gp/T/RtmpAODLeZ/downloaded_packages’
>
From what I've seen on other questions like this, I need to reinstall the packages to a new location. However, let's assume I'm an idiot and I have no idea how to re-install them somewhere else, where to install them, or how to make R/Rstudio that is where my packages can now be found. Can someone help me figure this out?
EDIT:
I now know that the problem is that it can't find the g++-7 dictionary, but I don't know why it is trying to find the g++-7, when my terminal says it my current version (12) is g++-12. Why would R not try to download the packages to my most recent version?
(base) Liams-MacBook-Pro:~ lessig7$ brew list gcc
/usr/local/Cellar/gcc/12.2.0/bin/c++-12
/usr/local/Cellar/gcc/12.2.0/bin/cpp-12
/usr/local/Cellar/gcc/12.2.0/bin/g++-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-ar-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-nm-12
/usr/local/Cellar/gcc/12.2.0/bin/gcc-ranlib-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-dump-12
/usr/local/Cellar/gcc/12.2.0/bin/gcov-tool-12
/usr/local/Cellar/gcc/12.2.0/bin/gfortran
/usr/local/Cellar/gcc/12.2.0/bin/gfortran-12
/usr/local/Cellar/gcc/12.2.0/bin/lto-dump-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-c++-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-g++-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-ar-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-nm-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gcc-ranlib-12
/usr/local/Cellar/gcc/12.2.0/bin/x86_64-apple-darwin21-gfortran-12
/usr/local/Cellar/gcc/12.2.0/include/c++/ (806 files)
/usr/local/Cellar/gcc/12.2.0/lib/gcc/ (719 files)
Once I realized R was trying to save it to an olde version, I tried to tell it to save to the new folder with the following code (just changing the version numbers to match what is on my terminal):
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
However, that produced the following error:
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
Warning in install.packages :
'lib = "/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include"' is not writable
Would you like to use a personal library instead? (yes/No/cancel)
Error in install.packages : unable to install packages
>
install.packages("dplyr", lib="/usr/local/Cellar/gcc/12.2.0/bin/c++-12/Library/Frameworks/R.framework/Resources/include")
I'd really appreciate any help. Thank you in advance.