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


#1

Hi - I am getting this error message quite often.

I don’t have Google Drive, which seems to have caused issues for others.

I downloaded Windows Process Explorer and searched for any processes using the .Rmd file (there were none). I then looked for the project directory and found a process for rsession.exe with <project directory>.Rproj.user\B12BF9AEF\source\s-4121B91\lock_file. There were another two processes for rsession.exe with the same PID, one process for rstudio.exe and one for explorer.exe .

Note: I downloaded the Process Explorer from here: https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer
and used the instructions here: https://www.howtogeek.com/128680/how-to-delete-move-or-rename-locked-files-in-windows/

I saved all files, closed down Rstudio, deleted the .Rproj.user folder and reopened. I was free of this message for a few hours but it has now returned.

I wonder if it is something to do with having TortoiseGit or Git Desktop - the project is a subdirectory of a version-controlled directory but I do have .Rproj.user in .gitignore…


#2

This has happened to me when my project was on OneDrive. I recreated the project in a local folder and now use OneDrive for manual backups/sharing. It's a bit of a pain, but using github would be no easier.


#3

When using an RStudio project on OneDrive for Business I pause syncing for a couple of hours (right-click the OneDrive icon in the system tray and select 'pause syncining > '. It's a minor irritation to turn it back on again, but it was the workflow I used when I used Google Drive.

Alternatifvely, you could try turning off syncing for the Rproject directory (right-click in your folder in Explorer and click on "Choose OneDrive folders to sync"), but I suspect similar issues might arise as other posts have noted for Dropbox and similar cloud services.