简体   繁体   English

无法在 R 中加载任何 package

[英]Can't load any package in R

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).我在 macOS Catalina 10.15.5 下运行 R(无法更新到最新版本,因为它需要 17GB 并且没有太多空间)。

Yesterday, RStudio stopped working (not loading libraries that used to work for me, like dplyr or tidyverse).昨天,RStudio 停止工作(不加载曾经为我工作的库,如 dplyr 或 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.我决定卸载并重新安装 R 和 RStudio,但没有任何改善。

Error (eg: Tidyverse):错误(例如: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’**

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’

EDIT编辑

> 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’

Any help on how to solve it?关于如何解决它的任何帮助?

By just dowloading the Command Line Tools package from Apple Developers adapted to the current macOS version solved the problem.只需从适用于当前 macOS 版本的Apple Developers下载命令行工具 package即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM