Rstudio and Google Drive


#1

Dear RStudio community members,

When working in the Windows environment I got the following message in a window:

“The process cannot access the file because it is being used by another process”

Is there any way to stop this message?

I also work with RStudio in a Mac environment but no issues there.

Best,

Manuel


#2

Are you working on a network drive? Or do you have software that would be indexing or backing up your development directory semi-continuously? I believe I’ve seen that issue in both of those cases.

Short of putting it on a local drive without backups :scream:, I don’t actually have a solution, though.

Edit: Just noticed the title of this thread. :grimacing: It’s definitely the sync program that is causing the problem, and I haven’t figured out a solution other than pausing it (at least when I ran into it with Dropbox).


#3

From what I understand, this is typically caused by RStudio and Google Drive (or other auto-synchronizing cloud storage providers) competing for access on files written by RStudio. Typically, these are the session-specific files written by RStudio into the (hidden) .Rproj.user folder, located in the project directory.

It’s currently not possible to configure where RStudio stores this project-specific state, but it may be possible to configure Google Drive to ignore that folder. This thread might help: https://webapps.stackexchange.com/questions/59260/how-do-i-prevent-a-specific-google-drive-folder-syncing-to-my-computer


#4

I get that message frequently when working with RStudio on a Windows. It can be very annoying! When I run into this issue, I just pause my Google Drive sync. You can follow the instructions here: https://productforums.google.com/forum/#!topic/drive/R8GuAY_g9so to the learn how to pause the sync.

Once you are done, you can resume the sync to make sure your files are still backed up.


#5

Thank you very much for the responses. I decided to pause Google Drive sync. Curiously, this problem did not happen on Mac.

Manuel


#6

Another option is to use insync (https://www.insynchq.com/) to sync your Google drive. Yes, you have to pay, but I started using the service almost a year and a half ago specifically because I replaced my Linux box with a Windows machine and started receiving these messages in RStudio. Everything was fine until I had to reinstall Windows last week and decide to give the native Drive Backup and Sync application a try. Messages are back, so I will be reinstalling insync tomorrow.

Cheers,

Simon


#7

To add here I was having related problems syncing project folders over Google File Stream on my GSuite account. This was mainly due to RStudio and git competing for resources with GFS as kevinushey suggests above. Thanks Kevin!

What I did to fix:

  1. Set the R Studio project folder to be available for offline access in Google File Stream. Without this R Studio did not know how to open files.
  2. Set .Rproj.user to be online only.
  3. Set .git to be online only.

No more problems, R Studio runs beautifully and my data, scripts, and outputs are synced to my GSuite account as I work!


#8

I am new to all of this. Could you describe where these options would be located in each program? I bounce between a desktop and laptop and run into this issue CONSTANTLY.
Thanks in advance!


#9

Great suggestion.
I know RStudio published a few instructions for Dropbox:
https://support.rstudio.com/hc/en-us/articles/200534477Using Dropbox with RStudio Projects

and the google drive ones above might be sufficient. I’d also like to see instructions for Box Sync.


#10

I couldn't get Google Backup & Sync to properly ignore the .Rproj.user folder or affected subfolders using its selective sync feature without it deleting required files or creating duplicate files that would cause the issue to persist. However, I did manage to solve the issue using symbolic links in Windows.

Steps:

  1. Close RStudio project
  2. Move .Rproj.user folder outside of Google Drive folder
  3. Create a symbolic link in the working directory using the following command in command prompt:
    mklink /d “C:\Users\Username\Google Drive\Project\.Rproj.user” “C:\Project\.Rproj.user”
  4. Right click symbolic link and select Properties > General > Hidden

If done correctly, RStudio will still be able to read/write from the .Rproj.user folder as if it were actually in the working directory, but Google Backup & Sync will completely ignore it while syncing all other files in the working directory.

Hope that helps.