Issue
When building an environment or installing a package inside a workspace, R raises an error similar to the following:Quick fix: specify a different CRAN mirror inline
Pass a different repo argument directly to install.packages():install.packages("renv", repo = "https://cran.r-project.org/")
This overrides the default mirror for this one installation call without changing any configuration files.
Permanent fix: update the default CRAN mirror
To avoid specifying therepo argument every time, update the default CRAN mirror using one of the options below.
Option 1: edit rsession.conf in your compute environment
Add the r-cran-repos setting to your rsession.conf file and point it to the correct CRAN mirror. For example:
r-cran-repos=https://cran.r-project.org/
Locate rsession.conf in your compute environment’s R session configuration directory.
Option 2: edit .Rprofile or Rprofile.site
Set the default CRAN mirror in your .Rprofile or Rprofile.site file. Find both files under your R home directory. Add the following:options(repos = c(CRAN = "https://cran.r-project.org/"))
- .Rprofile — applies settings for your user session only
- Rprofile.site — applies settings for all users on the system