diff --git a/R/rix_init.R b/R/rix_init.R index 8d10b3f2..c6bbfb45 100644 --- a/R/rix_init.R +++ b/R/rix_init.R @@ -418,7 +418,15 @@ nix_rprofile <- function() { if (isTRUE(is_nix_r)) { install.packages <- function(...){ stop("You are currently in an R session running from Nix.\nDon't install packages using install.packages(),\nadd them to the default.nix file instead.") - } + } + + update.packages <- function(...){ + stop("You are currently in an R session running from Nix.\nDon't update packages using update.packages(),\ngenerate a new default.nix with a more recent version of R. If you need bleeding edge packages, read the 'Understanding the rPackages set release cycle and using bleeding edge packages' vignette.") + } + + remove.packages <- function(...){ + stop("You are currently in an R session running from Nix.\nDon't remove packages using remove.packages(),\ndelete them from the default.nix file instead.") + } current_paths <- .libPaths() userlib_paths <- Sys.getenv("R_LIBS_USER") user_dir <- grep(paste(userlib_paths, collapse = "|"), current_paths, fixed = TRUE) diff --git a/tests/testthat/_snaps/rix_init/golden_Rprofile.txt b/tests/testthat/_snaps/rix_init/golden_Rprofile.txt index 6e58b31a..fbf2330d 100644 --- a/tests/testthat/_snaps/rix_init/golden_Rprofile.txt +++ b/tests/testthat/_snaps/rix_init/golden_Rprofile.txt @@ -24,6 +24,12 @@ install.packages <- function(...) { stop("You are currently in an R session running from Nix.\nDon't install packages using install.packages(),\nadd them to the default.nix file instead.") } + update.packages <- function(...) { + stop("You are currently in an R session running from Nix.\nDon't update packages using update.packages(),\ngenerate a new default.nix with a more recent version of R. If you need bleeding edge packages, read the 'Understanding the rPackages set release cycle and using bleeding edge packages' vignette.") + } + remove.packages <- function(...) { + stop("You are currently in an R session running from Nix.\nDon't remove packages using remove.packages(),\ndelete them from the default.nix file instead.") + } current_paths <- .libPaths() userlib_paths <- Sys.getenv("R_LIBS_USER") user_dir <- grep(paste(userlib_paths, collapse = "|"), current_paths, fixed = TRUE)