Skip to content

Commit

Permalink
fixes #234
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Rodrigues committed Jul 3, 2024
1 parent 692aa3c commit 51c19a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/rix_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/_snaps/rix_init/golden_Rprofile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 51c19a9

Please sign in to comment.