Installing package - cannot open file - permission denied

agwah picture agwah · Mar 15, 2017 · Viewed 73.8k times · Source

I'm working in RStudio and am attempting to install the dplyr package. I have installed various other packages without problem but have hit a problem with this.

It seems there are various parts to the install, some of these worked but the problem happens when I get 'the dependency BH'. This is the error:

>Installing package into ‘\\xxxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3’
    (as ‘lib’ is unspecified)
    also installing the dependency ‘BH’
    
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/BH_1.62.0-1.zip'
    Content type 'application/zip' length 16150075 bytes (15.4 MB)
    downloaded 15.4 MB
    
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/dplyr_0.5.0.zip'
    Content type 'application/zip' length 2556205 bytes (2.4 MB)
    downloaded 2.4 MB
    
>Error in install.packages : cannot open file '\\xxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3/file142032c9327b/BH/include/boost/function/detail/gen_maybe_include.pl': Permission denied

I have changed the directory/libpath as it did not appear that the file was downloading to the correct folder. file142032c9327b is now in the correct path, but path specified in the error is only correct up to /boost, there is no function folder here..?

I'm not sure if this missing folder is the issue, as the error says 'Permission denied', but it seems odd.

Answer

Shubham Yadav picture Shubham Yadav · Jun 10, 2018

I had the same issue. Tried doing the following and worked for me:

  1. Run the RStudio as administrator
  2. Under the Packages tab, click Install and change Install to Library option to C:/Program...../R/../library and select the desired package to install.

enter image description here

Hope it works.