How do I get out of a problematic renv loop ?

Hi,
I've been having a problem with renv. Here are the basics... running Rstudio Version 2023.03.1+446 (2023.03.1+446), R version 4.3, MacOS Monterey, 16 GB Ram.

The problem starts off with renv again, as usual, having a problem when I start R up. Renv usually has some kind of issue that requires that I run renv::status(). It usually is resolved fairly easily, but this time the problem seems like a loop I can't get out of. [Side note: I'm not sure how renv is supposed to work, but it seems that it always has issues]. Sometimes, renv::status returns the need to run renv::repair. I do that and usually, there is no problem however annoying it is.

However, this time the loop problem starts off the same way with many of my package's symlinks being broken. That happens occasionally. It usually is resolved by running renv::repair and it reinstalls all my packages. This is annoying and I don't know why this happens, but it's usually not really hard to resolve.

This time it's different. The whole sym links broken thing happens, renv::repair is run, but this time there is a problem. It happens that there are some packages that I've installed that are from GitHub. For some reason, the renv::repair is run and the reinstallation stops at the corpus package that I downloaded from GitHub. So the symlink problem never gets fully fixed. I rerun renv::repair() to the same result.

I have tried various approaches to resolving it, all to no avail.....(1) I upgraded renv. (2) terminate R or quit Rstudio and restart (3) restarted an R session (4) quit and restarted the computer (5) I reinstalled the corpus package from GitHub (6) I tried to remove the package from the renv.lock file, but it's not listed (???) (7) I tried running renv::settings$ignored.packages("corpus", persist = FALSE). So I end up back where I started with all the symlinks being broken, renv::repair running, and stopping reinstallation at corpus.

I am not sure what else to do other than more drastic measures like uninstalling R and/or Rstudio and/or every package. I'd like to avoid doing that if I can. Do you guys have any suggestions?
Thanks in advance,
Jose

Do you have any insight into what might be causing the symlinks to break in the first place?

I really don't know. Seems pretty random...sometimes it happens, sometimes it doesn't.

Do you have some sort of "cleanup" tool running on your machine? It sounds like something external to renv / RStudio might be deleting files within the renv global cache, leaving you with broken symlinks.

Hmmm, that's a good idea! There are a number of background processes going on...however, as for cleanup, the only thing is cleanmymac health monitor and menu....might be them. I suppose it could be them, but as far as I know, it's not cleaning things constantly. Worth trying to uninstall. You think it'll stop my immediate problem?

Here's an idea that I had. Since Kevinushey mentioned the renv global cache, I decided to look into it and see what I saw. It turns out that while all the other package folders in ~/Library/Caches/org.R-project.R/R/renv/binary/R-4.3/x86_64-apple-darwin20/repository/had a .tgz file in their respective folders, corpus didn't. I reasoned that maybe if I downloaded corpus from github and converted the .zip file to .tgz and put it into the folder, maybe the renv::repair() would actually finish. Unfortunately, this was the error message again...Error: error downloading 'https://cran.r-project.org/bin/macosx/big-sur-x86_64/contrib/4.3/corpus_0.10.2.tgz' [curl: (22) The requested URL returned error: 404]. Curiously, the file that I downloaded and installed was named...r-corpus-master.tgz. Maybe the name diff was it?

I'm happy to report that I seem to have solved the problem. Looking carefully through the functions of renv, I simply used the remove function to remove the offending package corpus. Once I did that, the renv::repair was able to complete its reinstallation. Upon running renv::status(), I got the frequent message

`renv::status()
The following package(s) are installed, but not recorded in the lockfile:
_
BiocManager [1.30.20]

Use renv::snapshot() to add these packages to the lockfile.`

I ran renv::snapshot() as usual and got back * The lockfile is already up to date.. So all is well that ends well.