14

.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
  • 27,285
  • 13
  • 133
  • 181
  • 3
    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

3 Answers3

6

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
  • 315
  • 4
  • 10
2

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
  • 784
  • 1
  • 10
  • 22
0

.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
  • 476
  • 5
  • 10