问题
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.
回答1:
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.
回答2:
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
回答3:
I had the same problem however could not find the mentioned sdb directory. Might be very obvious but just nuking everything and re-installing also works. I suffered a lot from this kind of problems when I was a beginner and didnt really understand what I was supposed to do in many cases so here is all steps in case any beginner ends up here:
First uninstall R. Then on terminal
sudo rm -rf ~/.rstudio
sudo rm ~/.Rhistory # probably redundant
Then reinstall it again.
来源:https://stackoverflow.com/questions/42501779/build-and-reload-in-rstudio-generates-save-file-error