Can't install any package in Mac

I am running R under macOS Catalina 10.15.5 (can't update to the newest version because it requires 17GB and it doesn't have so much space).

Yesterday, RStudio stopped working (not loading libraries that used to work for me, like dplyr or tidyverse).
After trying some codes like

update.package(checkBuilt = TRUE)

nothing changed. I have decided to uninstall and install again both R and RStudio, but nothing improved.

Error (e.g.: Tidyverse):

> install.packages("tidyverse", type="binary")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.2/tidyverse_1.3.2.tgz'
Content type 'application/x-gzip' length 420896 bytes (411 KB)
==================================================
downloaded 411 KB


The downloaded binary packages are in
	/var/folders/83/1hdhv2r97017s9xxs6yj5hl00000gn/T//Rtmp8tahja/downloaded_packages

> library(tidyverse)

**Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):**
** there is no package called ‘vctrs’**
> install.packages("vctrs")

  There is a binary version available but the source version is later:
      binary source needs_compilation
vctrs  0.5.0  0.5.1              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘vctrs’

trying URL 'https://cran.rstudio.com/src/contrib/vctrs_0.5.1.tar.gz'
Content type 'application/x-gzip' length 959562 bytes (937 KB)
==================================================
downloaded 937 KB

* installing *source* package ‘vctrs’ ...
** package ‘vctrs’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘vctrs’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/vctrs’
Warning in install.packages :
  installation of package ‘vctrs’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/83/1hdhv2r97017s9xxs6yj5hl00000gn/T/Rtmp8tahja/downloaded_packages’
> library(vctrs)
Error in library(vctrs) : there is no package called ‘vctrs’

The version I am running:

> version
               _                           
platform       x86_64-apple-darwin17.0     
arch           x86_64                      
os             darwin17.0                  
system         x86_64, darwin17.0          
status                                     
major          4                           
minor          2.2                         
year           2022                        
month          10                          
day            31                          
svn rev        83211                       
language       R                           
version.string R version 4.2.2 (2022-10-31)
nickname       Innocent and Trusting 
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_2.4.5 usethis_2.1.6 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        compiler_4.2.2    later_1.3.0       urlchecker_1.0.1  prettyunits_1.1.1 profvis_0.3.7    
 [7] remotes_2.4.2     tools_4.2.2       digest_0.6.30     pkgbuild_1.3.1    pkgload_1.3.2     memoise_2.0.1    
[13] lifecycle_1.0.3   rlang_1.0.6       shiny_1.7.3       cli_3.4.1         rstudioapi_0.14   curl_4.3.3       
[19] fastmap_1.1.0     withr_2.5.0       stringr_1.4.1     fs_1.5.2          htmlwidgets_1.5.4 rprojroot_2.0.3  
[25] glue_1.6.2        R6_2.5.1          processx_3.8.0    sessioninfo_1.2.2 purrr_0.3.5       callr_3.7.3      
[31] magrittr_2.0.3    promises_1.2.0.1  ps_1.7.2          ellipsis_0.3.2    htmltools_0.5.3   mime_0.12        
[37] xtable_1.8-4      httpuv_1.6.6      stringi_1.7.8     miniUI_0.1.1.1    cachem_1.0.6      crayon_1.5.2 
> packageVersion('tidyverse')
[1] ‘1.3.2’

Any help on how to solve it?

The easiest solution would be to answer "no" to this question, you would get a precompiled binary version that is a little older but much easier to install.
If you need to install the latest version from source, then you need to install Xcode in your system (not in R) and the recommended development tools for macOS systems.
https://mac.r-project.org/tools/

1 Like

Thanks a lot for your useful answers!!!

This topic was automatically closed 7 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.