Installing R & RStudio to Local Drive Not OneDrive

I've been trying to fix this for 2 days now.

I have tried 5 times and every time I installed R & RStudio, Sys.getenv("HOME") directs to my OneDrive. I don't want anything I do with R to be connected to my OneDrive in any shape or form.

I tried uninstalling and reinstalling R & RStudio, disabling OneDrive, and unlinking my OneDrive from my PC which now uses Windows 11. And HOME still goes to OneDrive.

I've tried to create a .Rprofile file, but 1) I can't seem to find out where RStudio starts up from and 2) I don't understand what Rprofile is supposed to look like for it to work (I also can't seem to save this as a RPROFILE file. It keeps saving as .txt).

I've looked at a number of resources including these and still no progress:
Rprofile - YouTube
(path - Change home directory for R - Stack Overflow)

I must not be understanding this because nothing I do is working and no progress is made.

I never had this problem on my previous machines since OneDrive was never automatically linked in previous Windows OS.

What am I missing? Thank you.

This is not an R or RStudio related variable, HOME is a system defined environment variable. Latest Windows versions automatically sync your home folder with OneDrive, which I personally find very annoying. You can opt out of this behavior by disabling one drive syncing in your Windows account settings, but I don't know how to change your user's HOME folder location after the fact. You might want to ask this on a Windows related forum.

Hmm...Yes, I really annoys me that Windows tries to push everything to the cloud when I work with sensitive info.

Thank you.

This is not an R or RStudio related variable, HOME is a system defined environment variable. Latest Windows versions automatically sync your home folder with OneDrive, which I personally find very annoying. You can opt out of this behavior by disabling one drive syncing in your Windows account settings, but I don't know how to change your user's HOME folder location after the fact. You might want to ask this on a Windows related forum.

Has RStudio, R-core team, or anyone in the R community actually tried reporting these issues to Microsoft? Or on the Microsoft forums? Or even to package developers who work at Microsoft such as this maintainer for 365 R.... to find out who from the Revolution Analytics team still works at Microsoft (GitHub - Azure/Microsoft365R: R SDK for interacting with Microsoft 365 APIs) ?

I bring it up because lately there has been a pattern on the forums of people having issue installing R and Rstudio.
If no one has brought it up to Microsoft, then I am willing make a post. However, I cannot do it by myself as I don't know each and every case that has had install issues within the community within the last 3 months. Which is why I ask if you have already made one already. Its a lot of information across many different community.rstudio.com posts to gather.

P.S. For my organization it was pure R and vctrs package in one case, the .Rprofile and internet.c missing in another, and Rstudio and rlang in the third. The first one was a hardware crash. And all have involved either a complete or partial upload to sharepoint. As @Cinji18 is experience the second issue, I will talk about that in my next post.

So about the .Rprofile . Technically R now stores things in your /AppData/Local folder as in "C:\Users\User.Name\AppData\Local\Programs". Given the link you provided earlier I am sure you already know this and that you need to unhide the folder so it easier to access.

This just leaves 3-6 major files that Rstudio/R need to run in your documents folder--Rhistory, .RData, and .Rprofile . The other 3 are the any temporary files of those first 3 files depending on whether you are in a project or the version of R you are running. As of 4.2.1 I have not seen those extra files being made in the documents folder. However, I don't know which version of R you are using so I am going to write my solution to address both.

**Generalized settings to do **

  1. On-Demand settings will crash your computer. Make sure they are unchecked Uncheck Save space and downlead files as you need them (first picture). If any in your IT complains, then tell them it a very unstable feature and may cause fatal crashes on your Window machine. If you need picture proof I can link then @ me and I link you to a different R community post with picture proof.
  2. Always keep on this device: Make sure .Rprofile, all .Rhistory, all .RData are "Always keep on this device" and have a dark green check mark next to them. A blue cloud symbol or cycle is bad (See picture 2 and 3 for images). Keep on disk forces the one-drive to pause for that file until you close the applicaiton that is using it. (See picture 2 and 3 for images)
  3. Keep the parent folder for .Rpofile and any config/msi file on disk: Finally this next setting applies to beyond just R, Rstudio but to Applicaiton such as Tableau, Excel Macros, ArcGIS, and more that may have configuration files in the documents folder. If you using R prior to 4.2.1 or any of the above programs make sure the parent folder for those program document also has "Always keep on this device" checked. So if you have .msi in your ArcGis 5.5 directory then the entire ArcGis Folder has to be kept on disk so that the file is kept on disk. Or if you have .Rprofile and your using in R 3.5.4 (which means the profile is still in the Documents Folder), then the entire Document folder has to be "Always keep on this device". (See picture 2 and 3 for images)
  4. Pause Sync while you work. Leaving it on can cause problems in Excel and R for multi-computer users: Finally you those out of the OneDrive/SharePoint woods? Oh no because if you have a cloud computer, virtual desktop, or using multiple computer then I strongly encourage you to pause whenever you use R, Excel, any non-Microsoft Product. One-drive feature was never really designed for a user to use more than one computer at the same time. In fact, the normally pausing behavior on OneDrive can become a one drive sync error. Neither Onedrive nor Teams was designed for pair programming or simultaneous collaboration
    Pic1SaveSpaceSetting
    Pic2DifferentOnedriveSettings

I don't think this qualifies as an issue from the Microsoft software side of things, they have taken the design choice to be pushi about the use of OneDrive but you can disable that feature and even completely avoid it when setting up your account.

R, on the other hand, doesn't play well with any cloud syncing software, not just Microsoft, they have mitigated the problem by moving the default user package library to the AppData folder but the synced HOME folder still causes problems in some cases along with the lack of utf-8 support (unless you enable an experimental feature that comes with other tradeoffs).

I'm guessing the R ecosystem as a whole is not moving fast towards supporting cloud synced setups on Windows because it is not a mainstream scenario, since most of the serious use of this tool is made on Unix based environments and GitHub doubles as a backup

It does when it leads to

When a change of configuration can cause the operating system to crash it is definitely falls under the wheel house of the developer of the operating system. I will speak more to this after my work meeting today.

Wow, thanks for all the input. I will definitely implement those recommendations.

After 3 days, I managed to figure out .Rprofile and .Renviron to appear to work I want, although I am uncertain whether R/RStudio has completely taken OneDrive out of their configurations. I even reinstalled them at a location without wifi hoping that would work.

Thank you.

They don't have OneDrive in their configurations, the HOME folder is set by the operating system (although you can overwrite it with a startup file) so you would need to create a new Windows account without OneDrive integration, it is not related to your R or RStudio installation.

I think I have a pretty good hunch of what is happening on your computer.

On a new Windows 11 22H2 installation, OneDrive folder is automatically there in your user folder. However it's likely not active, but the OneDrive folder is still in there.

Just remove the link to the PC in the OneDrive settings, which will remove the folder. Add your account back (or not) and choose another folder path if desired.

However the trick in OP's case is that he is likely using OneDrive, with documents backup on. What happens is that when on, OneDrive will forcibly move the documents folder to inside the OneDrive folder, causing it to be backed up inside the cloud. So the solution is easy : simply disable document backups in OneDrive.

Another trick that I've recently learned, is that you can move your library folders to a new folder path. For example, Sys.getenv("HOME") gets me "D:/Library/Documents", which you will note is neither in a onedrive folder, nor in the usual "C:/Users/user/Documents folder". I am actively using OneDrive and RStudio and I have no issue with this setup.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.