Custom RStudio snippets don't persist beyond current session

I switched to a new computer several months ago and since the switch, I haven't been able to get RStudio to save any new code snippets so that they persist into future RStudio sessions or other RStudio projects.

For example, in the RStudio IDE, if I open Tools --> Global Options --> Code --> Edit Snippets, I can add new snippets and save them. Those snippets are then available for that session in that project. But the new snippets don't show up in any other RStudio projects. And if I close the project in which I created the snippets and then reopen it, the new snippets I added are no longer show up in the snippets window. Only the default list of snippets is available.

In addition, I can't find the default snippets file on my system. The ~/.R folder does not contain a snippets folder or any files with snippets in the name.

Here's my system information:

Macbook Pro (15-inch 2018) running OS 10.13.6
RStudio 1.2.1511 Build 1365 (8add310b, 2019-04-22)
R version 3.5.3

If any additional information would be helpful for troubleshooting this, please let me know.

What is the output of:

stat -l ~/.rstudio-desktop ~/.R

on your machine? Are the folders owned by your user account (as opposed to root) and do they have the correct permissions for access?

1 Like

.R was owned by root, rather than by my user account. I changed the owner to my user account with chown and now snippets are being saved. I hadn't thought to check permissions and file ownership (but of course I banged my fist against my forehead and shouted "Doh!" as soon as I read your reply). Thanks Kevin!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.