Access denied for all R and RStudio activities (but not other apps) in previously used folders

Wondering if anyone may be able to offer assistance.

After having used R and RStudio successfully in my Windows 10 installation for more than one year, now I am unable to save files using RStudio or R in the same file location(s) I have used historically. For me, that is C:\Users\Scott\Documents\R<subfolders containing projects>, and which also includes the win-library folder.

With all other applications I am able to save files in these locations without issue. The Windows permissions appear to be fine.

  • I tried running RStudio as Administrator.
  • I tried renaming the C:\Users\Scott\AppData\Local\RStudio-Desktop folder.
  • I have installed the latest versions of R and RStudio, in that order, and restarted the system.
  • The problem seems specific to the R ecosystem at all folder levels below C:\Users\Scott where I am able to save from RStudio.
  • Due to the read-only/access denied issue, I am unable to save files, history, open project or update packages.
  • An example from the log file is ERROR system error 5 (Access is denied) [path=C:/Users/Scott/Documents/.Rhistory], which I know is basically a Windows error, but again it is only occurring with R-related activities.
2 Likes

Do you have the same problem if you try to access the files through vanilla R, or R from your console?

Problem exists as well with Vanilla R for sure. I'll experiment with console.

I think Plan B, or at least test B, will be to copy the concerning set of folders to another drive and see if I can just carry on.

Plan C will be to try a total uninstall reinstall.

I ask myself, "what changed"? At some point, I likely played around with trying to run RStudio from Anaconda and then backed out. I just can't be certain it was before or after the problem. Only a month ago it was all good, I was leveling up on leaflet and tmap, having a great time.

PS. Wow, I wasn't expecting a VIP to respond. Thanks!

1 Like

This file path from the log seems to be informative, although I don't see that it actually physically exists.

Jul 2018 03:14:44 [rsession-Scott] ERROR system error 5 (Access is denied) [path=C:/Users/Scott/Documents/.Rhistory]; OCCURRED AT: rstudio::core::Error rstudio::core::FilePath::open_w(rstudio_boost::shared_ptr<std::basic_ostream >, bool) const C:\Users\Administrator\rstudio\src\cpp\core\FilePath.cpp:1144; LOGGED FROM: void rstudio::r::session::{anonymous}::reportHistoryAccessError(const string&, const rstudio::core::FilePath&, const rstudio::core::Error&) C:\Users\Administrator\rstudio\src\cpp\r\session\RSession.cpp:338
28 Jul 2018 13:11:14 [rsession-Scott] ERROR system error 13 (The data is invalid) [project-file=C:/Users/Scott/Documents/R/companies/companies.Rproj, user-msg=the project directory is not writeable]; OCCURRED AT: rstudio::core::Error rstudio::session::projects::ProjectContext::startup(const rstudio::core::FilePath&, std::string
, bool*) C:\Users\Administrator\rstudio\src\cpp\session\projects\SessionProjectContext.cpp:178; LOGGED FROM: void rstudio::session::projects::startup(const string&) C:\Users\Administrator\rstudio\src\cpp\session\projects\SessionProjects.cpp:747
28 Jul 2018 13:12:36 [rsession-Scott] ERROR system error 5 (Access is denied) [path=C:/Users/Scott/Documents/R/companies/.Rhistory]; OCCURRED AT: rstudio::core::Error rstudio::core::FilePath::open_w(rstudio_boost::shared_ptr<std::basic_ostream >, bool) const C:\Users\Administrator\rstudio\src\cpp\core\FilePath.cpp:1144; LOGGED FROM: void rstudio::r::session::{anonymous}::reportHistoryAccessError(const string&, const rstudio::core::FilePath&, const rstudio::core::Error&) C:\Users\Administrator\rstudio\src\cpp\r\session\RSession.cpp:338
28 Jul 2018 13:12:41 [rsession-Scott] ERROR system error 5 (Access is denied) [path=C:/Users/Scott/Documents/.Rhistory]; OCCURRED AT: rstudio::core::Error rstudio::core::FilePath::open_w(rstudio_boost::shared_ptr<std::basic_ostream >
, bool) const C:\Users\Administrator\rstudio\src\cpp\core\FilePath.cpp:1144; LOGGED FROM: void rstudio::r::session::{anonymous}::reportHistoryAccessError(const string&, const rstudio::core::FilePath&, const rstudio::core::Error&) C:\Users\Administrator\rstudio\src\cpp\r\session\RSession.cpp:338

Well, now I'm totally at a loss.

  • renamed C:\Users\Scott\Documents.RData file
  • renamed C:\Users\Scott\Documents.Rhistory file
  • renamed C:\Users\Scott\Documents\R folder
  • renamed C:\Users\Scott\AppDat\Local\RStudio-Desktop folder
  • uninstalled RStudio
  • uninstalled all versions of R
  • uninstalled RTools
    ... everything a knew of for a clean install.
  • Restarted system
  • Reinstalled latest R
  • Reinstalled latest RStudio
  • opened RStudio and got the normal setup prompts.

No luck. In the new Users\Scott\Documents\R folder, there exists a clean win-library folder, but I cannot create a new directory project. I can, however, save a notepad file.

Fingers crossed, I think I found the problem: BitDefender had somehow decided to block:

  • R for Windows GUI front-end
  • RStudio
  • RStudio R Session

In BitDefender Internet Security 2018, this is under Protection | View Features | Safe Files | Application Access. I set the above three items to Allowed and was able to create a new project in the standard C:\Users\Scott\Documents\R directory.

No further updates shall indicate the problem is resolved, and hopefully, if anyone else runs into this issue you will be assisted by the above, at least as a possible root cause.

5 Likes

Glad you figured this out! :confetti_ball:

Preventing blacklisted — or just non-whitelisted — programs from altering user directories seems to be getting more common as a defense against ransomware. Again as a breadcrumb for any future searchers, this type of app-specific restriction is now also baked into Windows Defender, and can be turned on by system admins: https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-exploit-guard/controlled-folders-exploit-guard

1 Like