Skip to content

Commit

Permalink
Explain also why custom .Renviron.d/ and .Rprofile.d/ files are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Aug 2, 2024
1 parent be54186 commit 08150bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: startup
Version: 0.22.0-9001
Version: 0.22.0-9002
Title: Friendly R Startup Configuration
Depends: R (>= 2.14.0)
Suggests: commonmark, tools, tcltk
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## New Features

* `startup(debug = TRUE)` does a better job explaining why certain
Renviron and Rprofile files have been skipped.
Renviron and Rprofile files are skipped.


# Version 0.22.0 (2024-07-29)
Expand Down
14 changes: 11 additions & 3 deletions R/renviron_d.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ renviron_d <- function(sibling = FALSE, all = FALSE, unload = FALSE, skip = NA,
dryrun = NA, debug = NA, paths = NULL) {
debug(debug)

## Skip?
# (i) Find custom .Renviron.d/* files
if (is.null(paths)) paths <- find_renviron_d(sibling = sibling, all = all)

# (ii) Filter and source custom .Renviron.d/* files
files <- list_d_files(paths, filter = filter_files)

if (is.na(skip)) {
skip <- any(c("--no-environ", "--vanilla") %in% commandArgs())
if (skip) {
logf(" - Skipping %d .Renviron.d/* files, because R was launched with command-line option %s", length(files), paste(intersect(c("--no-environ", "--vanilla"), commandArgs()), collapse = " "))
}
} else if (skip) {
logf(" - Skipping %d .Renviron.d/* files because skip = TRUE", length(files))
}

if (!skip) {
# Load custom .Renviron.d/* files
if (is.null(paths)) paths <- find_renviron_d(sibling = sibling, all = all)
files <- list_d_files(paths, filter = filter_files)
files_apply(files, fun = readRenviron,
dryrun = dryrun, what = "Renviron",
debug = debug)
Expand Down
24 changes: 16 additions & 8 deletions R/rprofile_d.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,30 @@ rprofile_d <- function(sibling = FALSE, all = FALSE, check = NA,
check <- isTRUE(getOption("startup.check", check))
}

## Skip?
if (is.na(skip)) {
skip <- any(c("--no-init-file", "--vanilla") %in% commandArgs())
}

# (i) Check and fix common errors
if (check) {
check(all = all, fix = TRUE, debug = FALSE)
}

debug(debug)

# (ii) Find custom .Rprofile.d/* files
if (is.null(paths)) paths <- find_rprofile_d(sibling = sibling, all = all)

# (iii) Filter and source custom .Rprofile.d/* files
files <- list_d_files(paths, filter = filter_files)

if (is.na(skip)) {
skip <- any(c("--no-init-file", "--vanilla") %in% commandArgs())
if (skip) {
logf(" - Skipping %d .Rprofile.d/* scripts, because R was launched with command-line option %s", length(files), paste(intersect(c("--no-init-file", "--vanilla"), commandArgs()), collapse = " "))
}
} else if (skip) {
logf(" - Skipping %d .Rprofile.d/* scripts because skip = TRUE", length(files))
}

## Skip?
if (!skip) {
# (ii) Source custom .Rprofile.d/* files
if (is.null(paths)) paths <- find_rprofile_d(sibling = sibling, all = all)
files <- list_d_files(paths, filter = filter_files)
encoding <- getOption("encoding")
keep_source <- getOption("keep.source", TRUE)

Expand Down

0 comments on commit 08150bb

Please sign in to comment.