I moved from an older Mac to a new one. I copied my project folders to the new computer. When I open them on the new computer, I get my history, but none of my scripts open. I rely on the open scripts to help me manage my workflow, and some projects can have 15-20 scripts, in order. And I have many projects. So, I am hoping that I am missing something obvious to fix this. I tried opening RStudio on the new computer as root but that did not change anything.
New version of RStudio is 2021.09.1 Build 372 on Monterey 12.0.1. Old version is 1.3.959 on Mojave (10.14.6)
I'm 99% sure that the state of the open scripts is saved within the .Rproj.user directory (in the sources subdirectory specifically). It is a hidden directory, so you could double-check and make sure that it was copied along the rest. More risky, you could also try to copy sources and replace just that in your copied project (but do that on a separate copy, there is a non-zero risk that it breaks your project).
I'm not overly optimistic though, and really wish for your good that there is a better answer.
Maybe so. I have no way of finding these directories. Do you know where they are? And are you suggesting that I need to copy it from my old computer to a new one?
Yes, on your old computer, in each project's directory, there should be a subdirectory called .Rproj.user. Apparently on a Mac you can display hidden folders with the keyboard shortcut ⇧ Shift+⌘ Command+. and see if that directory is there. On your new computer, check that that directory is there too, if not, make sure you copy it.
If it is there on your new computer, you can also try copying specifcally my_project_folder/.Rproj.user/EFC23C9/sources/ to your new computer (you may need to replace EFC23C9 by something else). Be aware that this could break RStudio's project (it is just a wild guess from my part), so be prepared to delete the directory if needed, make a copy beforehand, etc.
Thank you. I didn't realize it was a hidden folder. The .Rproj.user folder is there.
In the one project I was working with yesterday, there is a "shared" folder as well as 2 other folders with 8 character names (2A65428F and 555E9848). The one starting with "2A" was created yesterday (after the move to the new computer). The one starting with "55" was last saved yesterday (before the move).
Under each of these, there appear to be two subfolders, "per" and "prop". In the "55" folder, both of these subfolders have dates from yesterday at 5:14 pm which sounds about right. Inside "per" are two folders called "t" and "u". The folder "t" is also dated yesterday and "u" is dated from July which may be when I created the project. Inside "t" is a list of files, each of which seems to be pointing to a source I had in my environment on my old computer.
It seems that RStudio ignored the "55" folder and created the "2A" folder instead and is now referencing that.
So, I guess the question is why RStudio is ignoring the "55" folder.
From looking at my old computer, the "55" structure is slightly different. Under "per" the "t" and "u" folders are empty. But there is another folder called "s-B28FA85E". This seems to have all of the proper sources listed there.
So, it is a bit of a mess and seems to be changes to how RStudio is managing sources.
So, I manually copied the contents of "t" from the "55" subfolder to the same location within the "2A" subfolder. All of the sources show up in the correct order. So it is just an issue of RStudio deciding to ignore the sources folder and creating a new one for some reason.
It worked. I really appreciate your help. Thank you.
I am hoping somebody from RStudio might be able to chime in and let me know whether there is a setting or other way of fixing this for my 50+ projects. Or to at least confirm that I am not breaking anything by doing it this way.
So, it turns out that you can literally just change the folder name starting with "55" to the folder name starting with "2A" and everything opens just fine. The "2A" folder must be specific to my new computer. Somehow RStudio knows it is looking for that folder and when it doesn't find it, it ignores the "55" folder and creates a new "2A" folder. So, before opening a project, I can just change the folder name and it should all work.
So, I assume this problem was caused because I am doing a clean install of everything on my new Mac. So, I assume this also means that there is a "settings" file in RStudio somewhere where the "2A65428F" is hard-coded? Can I just adjust a setting somewhere and change "2A65428F" back to "555E9848" and have RStudio recognize all the projects correctly? Or should I migrate my old settings file? I don't know how this works, or where this setting file might be, so any suggestions would be appreciated.
Great! I don't have the expertise of RStudio to say what potential problems that could cause, I see it more as a temporary fix than a robust solution.
To me, a workflow that relies on the current open tabs is inherently fragile, you should probably consider more robust approaches, e.g. with git, the package {targets}, or simply better naming conventions (depends a bit on what your workflow is).