Can
Can

Reputation: 4726

Installing a package inside RStudio fails on macOS Catalina

While trying to install a package inside RStudio on macOS Catalatina, it fails with a Permission Denied error:

> 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

Upvotes: 1

Views: 1754

Answers (1)

Can
Can

Reputation: 4726

As stated here by RStudio Support:

Are you able to install packages in R?

If you're having issues, we recommend trying to install packages in R (outside of RStudio) and see if you're able to do that. If not, please check the possible solutions below.

Therefore, one needs to:

  • switch to Terminal.app,
  • while inside your Terminal, your R console must be started with the sudo privileges. Otherwise, it will yet again fail with a permission denied error. Hence, inside your Terminal, type sudo R,
  • and then install whatever package is necessary: e.g. install.packages("mlbench").

Upvotes: 3

Related Questions