Rstudio and Google Drive Syncing Problems: "The process cannot access the file because it is being used by another process"

Google Drive-ApiRstudio

Google Drive-Api Problem Overview


So I'm using RStudio and storing my files on Google Drive (the version with folders on your system, acting like Dropbox). I'm using it because it provides a lot more space for free than Dropbox, and I need that space for the projects I'm working on.

When I attempt to write any document at all -- an R script, an RMarkdown file, etc... -- I get the error mentioned in the title. This doesn't happen using Dropbox. I have found answers for this question for Dropbox, but the solution (tell Dropbox not to sync the Rproj file) doesn't seem applicable to Google Drive (if it is, please correct me).

Currently, I'm pausing Google Drive, which is fine, but I often forget to resume it and that causes headaches.

Thanks for your help!

Google Drive-Api Solutions


Solution 1 - Google Drive-Api

EDIT: On further use of RStudio my solution didn't solve it - The sync popup just occurs at a lower frequency. The problem is that Google Drive currently doesn't have a feature to ignore Folders just filetypes.

--

This solved it for me:

  1. In Google Drive/Backup and Sync go to Preferences...
  2. Under My Computer click Change:
  3. Under Ignore files with these extensions add .rproj.user

See screenshots below:

Step 1

Step 2

Step 3

Solution 2 - Google Drive-Api

I also have been having this problem for a long time. The simplest solution is to quit/turn off GoogleDrive when working in RStudio. You are not going to have ongoing backups but it is not such a huge issue anyway. You can still sync to your drive during the lunch break or after the day. This might solve also the other issues that many people are having. All-in-all GoogleDrive is probably not the best backup solution. I think having the Drive just for e-mails and random shared documents (15-100 Gb) is still a good idea but for serious backing-up (at least 1 Tb) probably DropBox or some other solution is preferable.

Solution 3 - Google Drive-Api

I am not sure what caused this error, however I was able to resolve it by following the below steps :

Say you have got a file called temp.R which is giving you the error.

  1. Copy all the contents of temp.R and create a new file on your local drive (anywhere outside Google drive) and paste the contents there. Save it with some name say demo.R

  2. Now close temp.R from RStudio and move demo.R to google drive folder and now open it via RStudio file explorer.

You can now use demo.R as your new file and start working on it. It will also save all the changes you make henceforth.

So basically, we are just creating a new file and replacing it with the old one.

Solution 4 - Google Drive-Api

In addition to Oliver Oliver's answer, you may also want to add .Rhistory to Gdrive's list of things to ignore. Basically any file that's being updated as you type/work without explicitly saving has potential for a clash. I'd also add .DS_Store if you're on OSX.

Solution 5 - Google Drive-Api

This is not the OP's problem, but for those who are still scratching their heads, an RSelenium run may leave an orphaned Java process behind and cause the same error message via Rscript on the command prompt. How can you tell? Try deleting the .R file in question. It will say

> The action can't be completed because the file is open in java.exe

For a related issue, see https://github.com/ropensci/RSelenium/issues/228.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjpm_phdView Question on Stackoverflow
Solution 1 - Google Drive-ApiOliver OliverView Answer on Stackoverflow
Solution 2 - Google Drive-ApiPekkaView Answer on Stackoverflow
Solution 3 - Google Drive-ApiRonak ShahView Answer on Stackoverflow
Solution 4 - Google Drive-ApiBenbobView Answer on Stackoverflow
Solution 5 - Google Drive-ApiKimView Answer on Stackoverflow