installed new r 4.2.1 from R version 4.0.2 lost libraries and templates

I really messed up! ... on macos v10.14.6 I just installed new r 4.2.1 from R version 4.0.2 lost libraries and templates ... I don't know why I didn't read about this first ... is there any way to reinstall r 4.0.2? none of my projects are working now in rmarkdown ... help please?

and I can't install new RStudio because if I upgrade my MacOS I will lose a bunch of programs that won't run on 64 bit ... did I just ruin 100s of my R scripts and markdown projects?

New to RStudio Community

Don't panic.

I'm away from my mac, so this will be general, but in a few hours I can help you further, if needed.

For the libraries look at the FAQ for an overview.

In the console use path.package() to find out where the current installed version is looking for packages. The site-library folder will be somewhere under /Library. Look for the two R folders and copy (as administrator) the site library from the old to the new (don't move and leave the old as-is for the time being).

If you want to go back to 4.0.2, it's possible, but let's try getting libraries fixed first.

Thanx technocrat for your opening wise words "Don't panic" :wink: ... though I already did, I'm calming down a bit ... and bless you for your quick response!

As per your instructions to use path.package(), I found 2 libraries - the current new one 4.2 with 83 base packages, and 3.6 with 283 packages!

There is no 'site-library' folder, just a library folder containing folders of all the previous packages I've installed ...

Do I understand correctly that I would just copy the whole 3.6 library folder to the 4.2 library, or each of the folders within the 3.6 library to the 4.2 library?

would this overwrite the new current base library versions with the old version (many back to 2020 and 2021)?

I will check back to see any further directions ...
Thanx again for being willing to help out, and reduce some of my panic/anxiety!

Just back. Let me check on an actual Mac and I’ll let you know

I'm re-oriented to macOS. Installing packages can best be done by re-installing. I'll recreate an old script to gather the names of your packages from the previous version to do a batch install.packages(). This should be done because some packages that were compiled under the old version need to be recompiled for the current version.

Thanx so much for your thoughtfulness ... I kinda figured I'd have to reinstall them all, and after my initial shock, I was glad to know that I at least I've found the list of all my used packages in the old library folder ... I had already begun playing around to figure out how best to list the missing ones to do a batch install.packages(), but still in progress ...

If/when you have time to do your script-recreation, I'd really appreciate being able to use your old script please?

In the meantime, I've been slowly going through some of my recent R scripts and .Rmd files to start installing my more recently-used packages, and testing that my scripts still work with newer versions, with my fingers crossed (and getting some weird messages, but so far solve-able in my more recent scripts) ... not exactly the coding experiments I'd planned to continue with today, simply on the back-burner for now ...

Thanx again for your suggestions to get me started again!

I just recounted ... I had 1377 packages in my old R library!! ... no wonder I felt so anxious to seem like I'd lost them all ... that's a lot of manual install.packages() !!

Couldn't find my old script, fortunately, because this one is better

my_libs <- dir("/Library/Frameworks/R.framework/Versions/3.6/Resources/library")

options(install.packages.check.source = "no")


You can use this next time. It's long running with that many packages. For 300 packages over a 500Mbps connection, it take about a half hour.

It won't bring in packages originally install from non-CRAN sources or packages requiring compilation, because otherwise the script couldn't be run unattended as it would prompt periodically to get user input.

In general, most macOS users should only install binary versions, even if the source version is later. Most CRAN packages get binary versions 7-10 days after the source version become available. When installing packages individually it doesn't hurt to choose the install from source option and it will often work. If it doesn't work the first time, however, trying to troubleshoot it is not worth the time for anyone but advanced level users.

For the versions manually copied over, some will need to be re-installed because they depend on language feature missing from 3.x versions. That's the first thing to try.

In general, it's good practice not to lag behind R versions too much. Being on 4.1 rather than 4.2 is usually not a problem, but if it were to get up to 4.5, say, expect breakage—some packages will continue to work, others not.


Thanx so much for your time and effort to steer me in the right direction - this has been so helpful in my continuing journey to understand how to work more effectively with R!

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.