20

.Rproj.user/ is causing spamming on each git commit e.g.

    modified:   .Rproj.user/CE897349/sources/prop/238F1188
    modified:   .Rproj.user/CE897349/sources/prop/3B42583E
    modified:   .Rproj.user/CE897349/sources/prop/6FD5F454
    modified:   .Rproj.user/CE897349/sources/prop/B1FA156F
    modified:   .Rproj.user/CE897349/sources/prop/CA32C405
    modified:   .Rproj.user/CE897349/sources/prop/INDEX

These 'changes' don't seem important, e.g.

{
    "cursorPosition" : "19,0",
    "scrollLine" : "12",
    "tempName" : "Untitled3"
}

How did I get this directory in the first place, can I delete it (and preferably not have it return or appear in future projects)?

Note: the project is an R package.

stevec
  • 41,291
  • 27
  • 223
  • 311
  • 4
    These relate to the RStudio project (internal tracking of the state of the project). Best to create a file called `.gitignore` where the .Rproj file is. Then in that file put a line that says `.Rproj.user/`. It is also a good practice to put one separate lines `.RHistory` and `.RData`. This will instruct git not to watch these files. – MDEWITT Sep 04 '19 at 14:26

4 Answers4

11

As written on the official Rstudio page, the .Rproj.user stores some «project-specific temporary files (e.g. auto-saved source documents, window-state, etc.)». In other words, this directory is created along any R Project you make.

These files contain information related to some project options, such as:

  • Restore .RData into workspace at startup;
  • Save workspace to .RData on exit;
  • Always save history (even when not saving .RData).

I have configured my ~/.gitconfig file to have this directory always ignored when I start a local git repository. For how to do that, please look at this answer on StackOverflow. In other words: it's completely safe to have it ignored in your .gitignore file.

As far as deleting the directory is concerned, I never tried it. I guess it will get rid of any custom setting for your projects, perhaps reverting to default ones.

baggiponte
  • 547
  • 6
  • 13
3

I have the same problem with dropbox, and it seems that You can simply delete it. However You may lose your saved environment, but then You can just run everything from start again

Jørgen K. Kanters
  • 844
  • 1
  • 11
  • 22
2

.Rproj.user is a hidden directory where project-specific temporary files (e.g. auto-saved source documents, window-state, etc.) are stored.

If you delete it, you will not access to your history or these temporary files. Your project will still work - Rstudio will recreate the directory when you open the project.

https://support.rstudio.com/hc/en-us/articles/200526207-Using-RStudio-Projects

BMLopes
  • 546
  • 6
  • 10
0

You can rename a folder like that to something else (or move it to another folder) and then see if it causes problems. (.e.g, .Rproj.user => .Rproj.user.HIDE or move it to a subfolder /HIDE ...).

I just did that with one of my projects, and when I re-opened the project, the previously opened files were gone. I would have to load them.

When I copy the file back (and had to delete the new hidden version that was created during my test) and then restart the project, my RStudio session re-opens with the last set of files I was working on.

In both cases, the data seemed to be intact.

My issue is that that file is large, and I want to make a backup, but really only care about the source files. (Can't use GitHub in my work environment either.)

bbneo
  • 29
  • 5