22

I tried to build the R package hyperSpec using Windows Vista. When I do so, I get the following error message:

warning in file.copy(pkgname, Tdir, recursive = TRUE)
Problem copying .\hyperSpec\data\barbiturates.rda to C:\Users\JenZIG\AppData\Local\Temp\RtmpOEIqBD\Rbuilde446d3a290d\hyperSpec\data\barbiturates.rda: Permission denied

It is all the same whether I use the command line with R CMD build or R Studio's Build Tools (RTools installed, all package dependencies installed).

To solve the problem, I tried to change the path for the temporary directory or to manually set the permissions for the folders but without success. I tried to execute everything as administrator but again no success.

I think, a similar problem was discussed here:

https://stat.ethz.ch/pipermail/r-devel/2013-April/066389.html

However, there is no solution provided for this problem.

In addition, I have the same problem when I try to build the package with Win7.

Neoromanzer
  • 434
  • 2
  • 15
Marcel
  • 221
  • 1
  • 2
  • 4

2 Answers2

11

I had this problem. I had previously installed the package in question using the command line:

sudo R -e "install.packages('somepackage', repos='http://cran.rstudio.com/')"

Then when I tried building the somepackage package from source I got the permission denied message.

The solution was to run the following from the command line:

sudo R -e "remove.packages('somepackage')"

Then I was able to build and check somepackage from source.

EDIT

I see that the original question was specific to Windows. In that case I think you simply need to run a powershell window as administrator and use the following command:

Rscript.exe "remove.packages('somepackage')"
jsta
  • 3,216
  • 25
  • 35
  • 2
    I have experienced this problem intermittently (for a different R package which had to be built from source on Windows because it was not available as a binary from CRAN). I have been unable to discover what causes it (although since the link in the question suggests it is related to the need for administrator privileges, I will look into that next time it occurs). My *solution* has been to manually cleanup all old files from prior failed install attempts (ie delete /src-i386, /src-x64, and "R library"/"package-name", and try the install again - which (thus far) has worked for me. – Geoff Jul 30 '15 at 23:05
  • I think it should be `Rscript.exe -e "remove.packages('somepackage')"` on Windows. – Øystein S Aug 29 '18 at 04:50
0

What worked for me was unloading the package, removing the package, restarting R Studio, and then reinstalling it.

(in R Studio on the right hand side of the interface there is a tab called "Packages" that lets you do all of these things)

Philip
  • 638
  • 1
  • 8
  • 22