Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build and reload in RStudio generates 'Save File' error

I'm working on an Rcpp-enabled R package as a project in RStudio (version 1.0.136, Ubuntu 16.04 64 bit), and have recently started getting an error after building the package with Tools > Build and Reload. The error dialogue box reads:

Save File
No such file or directory 

The error doesn't appear straight after building and reloading. Rather, it occurs some time later while making edits to files, seemingly at random, and not necessarily while trying to save. However, after closing the dialogue box files cannot be saved without generating another error, this time with the message:

Error Saving File
No such file or directory 

Following that, the only way forward is to restart RStudio without saving any files, thus losing all changes.

It doesn't seem to be a problem with either roxygen2 or devtools since I've tried building with and without the Generate documentation with Roxygen and Use devtools package functions options in Tools > Project Options > Build Tools. I've also tried uninstalling andreinstalling RStudio as well as updating devtools etc, but the problem persists. I'm wondering if it's an issue in one of the package files such as NAMESPACE or DESCRIPTION. The package repository is available at https://github.com/shaunpwilkinson/insect.

like image 492
Shaun Wilkinson Avatar asked Feb 28 '17 06:02

Shaun Wilkinson


People also ask

Where does RStudio save files?

R saves your data to the working folder on your computer disk in a binary file. This storage method is efficient and the only drawback is that, because it is stored in an R binary format, you can only open it in R [there are some exceptions that will not be discussed here].

How do you save progress in RStudio?

You can save your script at any time (use Save in the File menu or the save shortcut, Ctrl+S or Cmd+S depending on your OS). After you've saved your work, close RStudio.


Video Answer


2 Answers

I ran into this error myself, and I'm posting what seems to have worked based on the comment from Shaun and a post on the RStudio support website.

The error is not limited to building a package; I encountered it while working in a bog standard RStudio project.

I found this comment from RStudio support here:

I think that if you clear the sdb (source data based) directory inside ~/.rstudio, then this might get things working for now.

So I closed RStudio, went into the terminal and removed the entire subdirectory .RStudio.user (inside the project directory, which is not what the comment above suggested directly). I restarted RStudio and voila. It works, and RStudio recreated the .RStudio.user directory.

WARNING: this will delete all the unsaved data including the contents of your environment and any unsaved files. You should copy the contents of unsaved files to another text editor before using this fix.

For future reference I am using RStudio 1.0.143 on OS/X 10.12.5.

like image 181
atiretoo Avatar answered Nov 15 '22 19:11

atiretoo


As per [1]: This usually implies that, for some reason, your user account does not have write permissions to the folder at ~/.rstudio-desktop (or ~/.rstudio for RStudio Server).

Solution:

sudo chown -R $(whoami) ~/.rstudio*

[1] https://github.com/rstudio/rstudio/issues/2037

like image 35
Tharsis Avatar answered Nov 15 '22 18:11

Tharsis