R install remains broken after after reinstall ("Error object 'il' not found" after start up)

Hi! I have a really odd problem with my R installation which I am not able to rectify even after reinstalling R on my system.

Upon starting Rstudio or an R interpreter in terminal I get the normal printout of current R version. However there is also an Error: object 'il' not found message. This message has persisted even after I uninstalled and reinstalled all R packages on my system, R itself, and Rstudio too. Here's how it looks like when I start R:

image

I am able to use most of R libraries without issue, however:

  1. I can't install packages via install.packages(). This prompts the Error: object 'il' not found error to halt execution of the installation. However, I can install packages through the terminal via sudo apt install r-cran-*.
  2. I cannot use the "knit" button in Rstudio. This prompts the Error: object 'il' not found error again.
  3. When I try to manually knit via knitr::knit(), it only generates an md output.

I have tried to rectify the problem by:

  1. Checking whether I had an .Rprofile that caused the error. I had no .Rprofile files. I created one which just prints "Loading custom .Rprofile" to see whether the object not found error occurs before or after .Rprofile is loaded. It occurs before any .Rprofile is loaded.
  2. I reset Rstudio settings to default.
  3. I uninstalled r-base-core, all r-cran- packages on my system, deleted user specific packages previous installed via install.packages() under my home directory, uninstalled Rstudio. Then I reinstalled all of them. The issue remains.

I am not sure how I'm even supposed to troubleshoot this cryptic error message. Any help would be appreciated.

Is there a way I can do a more thorough uninstall ensuring I've purged absolutely everything R related?

Can you run traceback() after starting R? Maybe it will give you a hint where the error is coming from.

Do you get the same error if you start R from the terminal, instead of inside RStudio?

This could be a broken R installer. Can you try installing another version of R?

Check the library/base/R/Rprofile file inside your R home, This is an internal profile that is loaded first.

Also check your .Renviron file(s). Unlikely that this could cause the problem, but just in case.

Thanks for the troubleshooting suggestions. I tried them:

  1. traceback() gives "No traceback available.".
  2. Same error from terminal as from inside Rstudio.
  3. Can't find any il object in library/base/R/Rprofile. Looks pretty normal. I tried printing some text at the end of the Rprofile, and the error about the missing object occurs after that text is printed.
  4. Installed another version of R (4.1.3.1 and 3.6.3-2). Unfortunately same error again.
  5. I have no custom .Renviron. And looks normal when it's recreated in /usr/lib/R/etc

Really strange. I must have probably messed something up on my system installing/removing other libraries. R used to work fine. Feeling this is gonna be hard to debug.

I wish markdown/knitting worked, then I could just ignore it, as I can manage without installing through install.packages(). Very obscure that this only affects certain specific functionality and persists over reinstalls.