Skip to content

Constant errors when editing a file synced to Google Drive  #7131

Closed

Description

@arencambre

System details

RStudio Edition : Desktop
RStudio Version : 1.3.959
OS Version      : Windows 10
R Version       : 4.0.1

Steps to reproduce the problem

Edit a file that is saved in a folder that the Google Backup and Sync app is syncing to Google Drive.

Describe the problem in detail

Repeatedly, you will get an error that says The process cannot access the file because it is being used by another process:
image

Less commonly, you'll get an error that says The file [filename] has changed on disk. Do you want to reload the file from disk and discard your unsaved changes?:
image

#3837 's wording or comments suggests a belief that it would fix more than just Dropbox. It does not fix this problem with Google Drive.

This is the only software I use that has so many problems with Google Drive. It is highly desirable for RStudio to be compatible with Google Drive as it provides a recovery option for data loss in cases where version control cannot help, including between check-ins/pushes or if the user does not use version control.

Describe the behavior you expected

Editing a file in a folder synced by Google Drive creates no errors.

Activity

  1. changed the title [-]When editing a file, RStudio repeatedly has errors when syncing with Google Drive [/-] [+]Constant errors when editing a file synced to Google Drive [/+] on Jun 15, 2020
  2. kevinushey commented on Jun 15, 2020

    @kevinushey
    Collaborator

    Internal note: this likely occurs because RStudio's autosave (which saves files to the project .Rproj.user folder) is attempting to access files currently read and locked by Google Drive.

    We could also try alleviating this by allowing for a retry timeout when we're attempting to open a file handle.

  3. ronblum commented on Jun 15, 2020

    @ronblum
    Contributor

    2nd internal note: @kevinushey would this solution affect files outside of a project as well? I haven't been able to consistently reproduce this with just autosave, but I can consistently do so by repeatedly typing and saving fast enough till Google Sync and I have been in conflict (not a realistic scenario, but it forces the issue).

  4. kevinushey commented on Jun 15, 2020

    @kevinushey
    Collaborator

    @ronblum: I believe this would affect files opened both inside and outside a project, as in each case files within the project's .Rproj.user will need to be updated.

  5. kevinushey commented on Jun 22, 2020

    @kevinushey
    Collaborator

    These errors are likely coming from here:

    using namespace boost::iostreams;
    HANDLE hFile = ::CreateFileW(m_impl->Path.wstring().c_str(),
    GENERIC_READ,
    FILE_SHARE_READ,
    nullptr,
    OPEN_EXISTING,
    0,
    nullptr);
    if (hFile == INVALID_HANDLE_VALUE)
    {
    Error error = LAST_SYSTEM_ERROR();
    error.addProperty("path", getAbsolutePath());
    return error;
    }
    boost::iostreams::file_descriptor_source fd;
    fd.open(hFile, boost::iostreams::close_handle);
    pResult = new boost::iostreams::stream<file_descriptor_source>(fd);

    We could potentially resolve this in a couple ways. If we see this particular error, we could:

    1. Wait a small amount of time, and then try again to re-open the file;
    2. Try also opening the file using GENERIC_READ | GENERIC WRITE (although this is more dangerous, since we could then end up attempting to read a file at the same time a process is trying to write to it)
  6. added this to the v1.4 milestone on Jun 22, 2020
  7. matthewberryman commented on Sep 4, 2020

    @matthewberryman

    It's not autosave—turning it off just simply stops it being a frequent issue. We are seeing this issue intermittently with Dropbox on manual save and with all autosave off, at ~ same frequency as reported here.

    Dropbox version 104.4.75, Windows 10 x64 (build 17763), R Studio 1.3.1073 and R 4.0.2.

    Some sort of exponential back-off process variation on 1 would seem to me to be the best solution.

  8. 25 remaining items

  9. cchen22 commented on Jun 12, 2023

    @cchen22

    Can anyone let me know the best solution for this problem with Google Drive by 2023? Thanks!

  10. gdickens commented on Aug 25, 2023

    @gdickens

    Would like to know this too. Has been a constant problem for me.

  11. modified the milestones: Backlog-2, Later on Oct 5, 2023
  12. thk686 commented on Dec 1, 2023

    @thk686

    The problem is that the directory .Rproj.user is required to exist within the project source tree. The .Rproj.user is not compatible with network drives. My guess is that RStudio uses git or something similar within this directory. Git is not compatible with network drives as it relies on specific checksumming behavior. There is a trivial fix that has been suggested but complete ignored by Posit/RStudio folks. If we had the option to place this directory outside of the project tree, these problems would disappear. This directory is only there to cache information. You can delete it and it will be recreated in the next session. Therefore, it does not need to be in the project tree. It could, for example, exist in our home directories or in scratch space somewhere. I cannot understand why this is not an option.

  13. gdickens commented on May 15, 2024

    @gdickens

    This still seems to be an issue. My solution is to close Google Drive before I start working on an R Project. I'll then start google drive again to sync everything once I'm finished working on the project.

    Obviously this isn't ideal.

  14. removed this from the Later milestone on May 16, 2024
  15. added this to the Cranberry Hibiscus milestone on Jun 23, 2024
  16. ronblum commented on Jun 24, 2024

    @ronblum
    Contributor

    This should be fixed in one the latest daily builds of the release in progress, Cranberry Hibiscus 2024.07.0. If anyone would be willing to try it out, it would be much appreciated. Note that these builds are meant for testing purposes only, not production.

  17. gtritchie commented on Jun 25, 2024

    @gtritchie
    Member

    This should be fixed in one the latest daily builds of the release in progress, [Cranberry Hibiscus 2024.07.0]

    Note that the fix requires configuring the project to store .Rproj.user somewhere other than the cloud drive, see #14875.

  18. ronblum commented on Jul 9, 2024

    @ronblum
    Contributor

    Closing as fixed. If anyone still runs into this issue, please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugneed help verifyingremote storage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions