At present I have several RStudio projects in a OneDrive folder for a research project. Unfortunately that creates a sync issue which blocks any synchronisation of my OneDrive folder. the problem is lock_file within a session subfolder under .Rproj.user. The error message is "This file is in use". I have tried putting the projects in a folder outside OneDrive, and attempted to set up a backup of the folder using OneDrive settings. That does not work either because I use renv for package management, which creates symlinks, and that stops me setting up backup for ANY files or folders at all within my Documents folder (!). I also tried Daniel Bride's onedrive_sanitize, but that did not work either. It created symlinks in the OneDrive folder when run, but if the project is re-opened, it creates the temporary session files inside OneDrive that cause the problem. At present, my only workaround is to close RStudio whenever I want or need OneDrive to synchronise, which works, but is a PITA. Any other suggestions?
I use Google Drive for RStudio projects rather than OneDrive, and used Dropbox in the past. The selective sync feature for Dropbox dealt with the .Rproj.user folder unti it didn't anymore. When I switched to Google Drive I purchased a license for insync software and set an Ignore Rule for that folder. All has been well for several years now. Their web site is www.insynchq.com. It works for OneDrive, Google Drive and Dropbox and runs on macOS (finally native on Apple Silicon!), Windows and Linux. I have a grandfathered lifetime developer license that includes the required Ignore Rules feature.