Hello, Ive been getting errors every time I try and install any packages into R. Ive looked through every page online and have updated Rstudio (1.3.1093) and my Mac to Big Sur (11.0.1) and neither have helped.
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace ‘rlang’ 0.3.1 is being loaded, but >= 0.4.6 is required
ERROR: lazy loading failed for package ‘tidyselect’
* removing ‘/Users/jameshallam/Library/R/3.4/library/tidyselect’
* restoring previous ‘/Users/jameshallam/Library/R/3.4/library/tidyselect’
Warning in install.packages :
installation of package ‘tidyselect’ had non-zero exit status
ERROR: dependencies ‘lifecycle’, ‘pillar’ are not available for package ‘tibble’
* removing ‘/Users/jameshallam/Library/R/3.4/library/tibble’
Warning in install.packages :
installation of package ‘tibble’ had non-zero exit status
ERROR: dependencies ‘lifecycle’, ‘tibble’ are not available for package ‘dplyr’
* removing ‘/Users/jameshallam/Library/R/3.4/library/dplyr’
Warning in install.packages :
installation of package ‘dplyr’ had non-zero exit status
ERROR: dependencies ‘dplyr’, ‘tibble’, ‘lifecycle’ are not available for package ‘tidyr’
* removing ‘/Users/jameshallam/Library/R/3.4/library/tidyr’
Warning in install.packages :
installation of package ‘tidyr’ had non-zero exit status
ERROR: dependencies ‘dplyr’, ‘tibble’, ‘tidyr’ are not available for package ‘broom’
* removing ‘/Users/jameshallam/Library/R/3.4/library/broom’
Warning in install.packages :
installation of package ‘broom’ had non-zero exit status
ERROR: dependencies ‘tidyr’, ‘broom’, ‘tibble’, ‘dplyr’, ‘car’ are not available for package ‘rstatix’
* removing ‘/Users/jameshallam/Library/R/3.4/library/rstatix’
Warning in install.packages :
installation of package ‘rstatix’ had non-zero exit status
This is a section of the error. I'm not sure if this is just a Mac glitch. I've tried installing the packages one at a time and this doesn't work either.
The error message is asking you to update the rlang package. Restart your R session and try installing the latest version with
install.packages("rlang")
Note: Since you are using an old R version (3.4), most likely you are going to have to compile from source, which means you need to install the recommended development tools for macOS systems. https://cran.r-project.org/bin/macosx/tools/
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘rlang’
Warning in install.packages :
installation of package ‘rlang’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/sy/g1s2z9jj15x2h2xh1brmcjvw0000gn/T/Rtmpeznuwm/downloaded_packages’
library(rlang)
Warning message:
package ‘rlang’ was built under R version 3.4.4
As I said, for installing packages from source you need the recommended development tools for macOS systems (the error message refers XCode). Although, I would recommend updating your R version so you can have access to precompiled binaries.
This seems self explanatory, you are missing package dependencies, so you have to install them.
Also, I should note that you are still using the old 3.4 R version so installing packages is going to be much harder for you since most of them are going to require compilation.
This says 3.4 but Ive just reinstalled the 4.0.3 version.
Installing package into ‘/Users/jameshallam/Library/R/3.4/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘cow’ is not available (for R version 3.4.3)
Error in readRDS(pfile) :
cannot read workspace version 3 written by R 4.0.3; need R 3.5.0 or newer
It seems you have both versions installed in your system but it is configured to use the older one, sadly I can't tell you how to solve this since I'm not a macOS user but hopefully someone else will.
then do you have any .libPaths setting specified in a startup profile like
~/.Rprofile that are overriding the defaults?
Also, if you type Sys.getenv("R_LIBS_USER"), what do you get?
I think when I updated my R version, I had to manually create a folder called 4.0 in ~/Library/R
so that .libPaths could find it. Once you get .libPaths pointing to the right directory, you have a couple of methods of updating packages.
Option 1: The clean way - re-install all the packages from scratch.
Option 2. The quick and dirty way: Rename the 3.5 folder to 4.0 and run update.packages(checkBuilt = TRUE).
when I type .libpaths() In my Studio console I get:
"/Users/jameshallam/Library/R/3.4/library" "/Library/Frameworks/R.framework/Versions/3.4/Resources/library"
when I type in Sys.getenv("R_LIBS_USER") I get:
"~/Library/R/3.4/library"
Hmm. The only thing I can think of this point is manually add a "4.0" folder
inside of /Users/jameshallam/Library/R/, make sure you don't have any Rprofile or Rprofile.site files lurking around your home folder and download and reinstall a new copy of the R installer.
To check for Rprofile files that might affect startup:
If the file list is not empty, check those files to see if you have "hardwired"
.libPaths pointing to the old version.
If this filelist is empty, if you reinstall the CRAN version R after adding in the folder "4.0" inside of /Users/jameshallam/Library/R/, that should be able to be picked up by .libPaths.