在macOS Catalina上的RStudio中安装软件包失败

时间:2019-11-06 10:15:30

标签: r rstudio macos-catalina

尝试在RStudio上的macOS Catalatina,内安装软件包时,失败并出现Permission Denied错误:

> install.packages("mlbench")
trying URL 'https://cran.rstudio.com/src/contrib/mlbench_2.1-1.tar.gz'
Content type 'application/x-gzip' length 920768 bytes (899 KB)
==================================================
downloaded 899 KB

* installing *source* package ‘mlbench’ ...
** package ‘mlbench’ successfully unpacked and MD5 sums checked
mv: rename /usr/local/Cellar/r/3.6.1_1/lib/R/library/mlbench to /usr/local/Cellar/r/3.6.1_1/lib/R/library/00LOCK-mlbench/mlbench: Permission denied
ERROR: cannot remove earlier installation, is it in use?
* removing ‘/usr/local/Cellar/r/3.6.1_1/lib/R/library/mlbench’
Warning in install.packages :
  installation of package ‘mlbench’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/bc/wsz930gj3gn5zgq4hbm6jkfr0000gn/T/RtmpdvQLox/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning in install.packages :
  cannot create file '/usr/local/Cellar/r/3.6.1_1/lib/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages :
  cannot update HTML package index

1 个答案:

答案 0 :(得分:0)

如RStudio支持here所述:

  

您可以在R中安装软件包吗?

     

如果遇到问题,建议您尝试在R中安装软件包   (在RStudio之外),看看您是否能够做到这一点。如果没有,请   请在下面查看可能的解决方案。

因此,需要:

  • 切换到Terminal.app
  • 但是,R控制台必须以sudo特权启动(否则,它将再次失败,并出现perssion拒绝错误):sudo R
  • 然后安装所需的任何软件包:install.packages("mlbench")