英文:
Viewing the deleted source code of an R script that is currently executing
问题
我相信我遇到了与这个问题中的人相同的问题:https://stackoverflow.com/questions/33074305/how-to-prevent-objects-from-automatically-loading-when-i-open-rstudio
简而言之,当我打开RStudio时,今早的旧代码弹出并保存,覆盖了几小时的工作。与Microsoft Office不同,我看不到Rstudio恢复丢失文件的选项。在搜索中,我将全局自动保存选项更改为“备份未保存的更改”。那现在也没有帮助。
我将添加自己的答案,说明如何恢复我的工作,但如果有更好的主动解决方案,我愿意倾听并分享必要的信息。
英文:
I believe that I am experiencing the same issue as the fella in this question: https://stackoverflow.com/questions/33074305/how-to-prevent-objects-from-automatically-loading-when-i-open-rstudio
In short, when I opened RStudio, the old code from this morning popped up and then saved, overwriting hours of work. Unlike Microsoft Office, I don't see an option for Rstudio to recover a lost file retroactively. In my search, I did change my Global auto-save option to "Backup Unsaved Changes". That doesn't help now.
I will be adding an answer of my own of how I recovered my work, but if there's a better, proactive solution, I'm all ears and can share necessary info.
答案1
得分: 1
如果/.local/share/rstudio/sources/
目录中有会话目录,那么您丢失的文件可能位于其中某个会话的*-contents
文件中。我的第一次搜索引导我到这里,那里我找到了R.home(component = "home")
来导航到我的R安装目录。在这个系统上安装了几个R的版本。然而,这并没有解决问题,因为没有相关的启动文件似乎是导致我的问题的罪魁祸首,也没有解决我的丢失工作的方法。更多搜索引导我来到这个问题:https://stackoverflow.com/questions/58681060/rstudio-keeps-loading-prior-session-with-no-files-and-wont-run-commands...评论指向我这里,我可以看到~/.local/share/rstudio
是另一个线索,而且确实如此!虽然我有我的主目录下的.RHistory,但这个目录中有一个名为history_database
的备份副本,带有时间戳,让我可以查看我在Rstudio中进行的交互式工作。但最重要的部分是我编写的脚本,发送并丢失了它。幸运的是,在/.local/share/rstudio/sources/
中有一个session*
目录,其中的文件的时间戳与我启动脚本的时间相匹配。该目录中的文件以8位十六进制值命名,对于每个文件,都有一个包含正在运行的脚本的*-contents
文件!不幸的是,它不会记录随之的源文件,但这总比记住我做了什么并且摸索着尝试重新创建一些,让我们说创造性工作好得多。
英文:
TL;DR If there are session directories in /.local/share/rstudio/sources/
, then your lost file is inside one the sessions' *-contents
files.
My first googling brought me here where I found R.home(component = "home")
to navigate me to the my R's install directory. There are a few versions of R installed on this system. However, that was a bust, as there were no relevant startup files that appeared to either be the culprit of my issue, or my solution to my lost work.
Some more searching landed me on this question:
...whose comment pointed me here where I could see that ~/.local/share/rstudio
is another clue to follow, and it was! While I have my home .RHistory, this directory has a spare copy with timestamps called history_database
, allowing me to see the interactive work I did in Rstudio.
But the most important part was the script I wrote, sent off to run and then lost it. Thankfully, in /.local/share/rstudio/sources/
there was a session*
directory with files with a timestamp matching the time I started the script. The files in that directory are named as 8-digit hex values, and for each there is a *-contents
files which contains the script that is being ran!
Unfortunately, it doesn't keep a record of the sourced files that go along with it, but that's better than remembering what I did and fumbling about trying to recreate some of my, let's say, creative work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论