0

I have accidentally unlinked my library.

unlink(C:/Users/.../R/win-library/3.6")

So I reinstalled R and R Studio. Since this, I have a lot of trouble. If I want to install a package e.g.

install.packages("haven") 

or

install.packages("haven", dependencies = TRUE)

I get this message:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

Error in install.packages : cannot open file 'C:/Users/.../R/win-library/3.6/file2d6465c81796/backports/DESCRIPTION': Permission denied

I installed and reinstalled R a couple of times in the past, but I never had these issues. So it must have something to do with the unlink operation I did before. Furthermore, R installs a huge amount of additional package if I want to install a package (e.g.haven).

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/.../R/win-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘backports’, ‘digest’, ‘glue’, ‘zeallot’, ‘assertthat’, ‘utf8’, ‘ellipsis’, ‘magrittr’, ‘rlang’, ‘pkgconfig’, ‘vctrs’, ‘R6’, ‘clipr’, ‘crayon’, ‘BH’, ‘cli’, ‘fansi’, ‘pillar’, ‘forcats’, ‘hms’, ‘Rcpp’, ‘readr’, ‘tibble’


sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.1 tools_3.6.1  
Banjo
  • 1,191
  • 1
  • 11
  • 28
  • Did you try to re-install Rtools as suggested by the error message? – Chelmy88 Sep 24 '19 at 09:23
  • A workaround for "Permission denied" would be launching R from the terminal with `sudo R` and then installing your package. You can go back to Rstudio to use the package. Ugly but does the job for me. – haci Sep 24 '19 at 09:25
  • @ Chelmy88: No, nothing changes if I install RTools. – Banjo Sep 24 '19 at 09:28
  • @ haci: Yes I read this fix here: https://stackoverflow.com/questions/32540919/library-is-not-writable. However, I never had this issue before. So something muste have changed. – Banjo Sep 24 '19 at 09:30

1 Answers1

1

Bitdefender was the reason, which I had installed since I installed R and R studio last time. You have to change the settings in security (Schutz) --> secure files (Sichere Dateien) --> application access (Anwendungszugriff) and enable R and RStudio (Please edit this if the Englisch meaning in Bitdefender is different since I have the German version).

Banjo
  • 1,191
  • 1
  • 11
  • 28