On Windows 10, R uses the user's **Documents** folder for storing all libraries. While technically permitted, this is causes problems: - The **Documents** folder is conventionally for user-created documents. For the vast majority of uses of R, the modules are the opposite, simply "things I downloaded to make my program work". - This causes problems with increasingly common cloud file backup utilities that back up the user's **Documents** folder. If you use OneDrive, Google Backup and Sync (Google Drive), and more, your **Documents** folder is backed up by default now. This means every time you install or update libraries, you're creating a lot of pointless work and network traffic for these non-original files to be backed up. Also, this may cause errors if there are collisions between the cloud sync utility and the module-installation process. Since placing libraries in the **Documents** folder suggests that R's devs see libraries as a per-user deal, I recommend moving libraries to the AppData folder. On Windows 10, it is customarily at **C:\Users\*username*\AppData\Local**. I am not certain, but I think this is represented by **CSIDL_LOCAL_APPDATA** constant in Windows.
Just updated the title as I remembered hows R stores or references certain settings files, like .Renviron and .Rhistory, in the **Documents** folder. These, too, would make more sense in **AppData\Local**. The only exception I can think of for these is if they are commonly user-edited. In my experience, user edits of these files are unusual and typically done by advanced users, so there is probably little value in keeping them in the **Documents** Folder.
You might respond with, "but dummy, R installs into Program Files, not your documents folder!"
Nope: If your Windows computer is connected to a domain, which is typical in corporate environments, then your computer does per-user/non-administrative installs of products when the option is available. This means the installer does not ask for administrator privileges, and the program goes into a directory specific to that user instead of in Program Files.
The problem is that when R is installed without admin privileges, the recommended directory is one's own Documents folder. This needs to be changed to a more sensible default, as specified in my initial comment.
You're not the only ones running into this. RStudio has the same problem: https://github.com/rstudio/rstudio/issues/8598
Oops, I wish you permitted editing or deleting of comments. My prior comment is incorrect. Even on a domain-connected computer, R installs to C:\Program Files\R\R-4.0.3. The problem appears to be limited to libraries and certain other files. These do not belong in a user's Documents folder.
Per-user installation of R without administrative permissions in a released version of R is currently broken, only recently fixed in R-devel. The desktop icon in released versions is installed always into the shared desktop, which would fail without administrative permissions. In R-devel, it would now correctly install into user desktop. Still, one may install without the desktop icon with an override from the command line. Have you been doing that when installing released versions per-user? I am not sure how you managed to do per-user installation, but then I've not installed R with a domain. On my system I can do a per-user installation without administrative rights only now in R-devel, because I've recently added a command line option to do that. And your original comment was correct, the default installation directory is my documents folder, but I can easily override that again from the command line. I am sympathetic that today, neither R itself nor libraries should go into the Documents folder. Maybe even the configuration files, there is now confusion where they are, for some libraries there may be more versions (one in home, one in documents). These default installation directories were chosen very long time ago when Windows were very different (and e.g. only had one home directory) and since then users got used to the defaults. I'd be much more open to adding more command line options to the installer, and especially if that suggestion came with a well-tested patch, to allow expert administrators to customize the installation as needed, rather than changing the behavior for technically less skilled end users who got used to what is being done. As Windows change often (compared to R), there is a risk of oscillation, etc.
Per-user installation of R...
Because this garbage bug-tracking system won't let me edit my comments, there may be confusion. This issue is only about where R puts the libraries.
While I wandered a bit in comment 2, I retracted my wander in comment 3. I tested and was not able to do a per-user install, so I mis-remembered that part. Had I been able to edit, I could have deleted my poorly conceived wander.
...neither R itself nor libraries should go into the Documents folder
Yup, agree. And a switch needs to be made. Perhaps on the next major release, R could implement a smarter default location for libraries and have an installer option for people who need the old way.
RStudio just fixed their similar issue. :-) https://github.com/rstudio/rstudio/issues/8598
Changed in R-devel together with switching to UCRT. The default installation location without administrator privileges is now the user program folder (e.g. C:\Users\username\AppData\Local\Programs). The default location for the personal library is now the local application data (e.g. C:\Users\username\AppData\Local).