Error: cannot add binding of 'main.dir' to the base environment [duplicate]

I was using R and Rstudio with no specific problem. However, since today every time I open R, the following message appears:

Error: cannot add binding of '.First' to the base environment.

Therefore, the same problem arise when I try to use RStudio. I haven't made any change to my computer or its system and its seems the problem appears suddently.

I used Windows 10 all updated installed, R version 4.1.0.

I have reinstalled R, updates every programs but the problem remains.

Any idea of what is going on ?


According to the R-devel message board, this is solved by using assign() in the .Rprofile. Previously one could assign these as objects directly,

.First <- function() cat("\n   Welcome to R!\n\n")
.Last <- function()  cat("\n   Goodbye!\n\n")

but R 4.1.0 has the following breaking change:

The base environment and its namespace are now locked (so one can no longer add bindings to these or remove from these).

The following method should now be used:

assign(".First", function() cat("\n   Welcome to R!\n\n"), envir = globalenv())
assign(".Last", function() cat("\n   Goodbye!\n\n"), envir = globalenv())