Skip to content

option setters clear other settings #655

@aronatkins

Description

@aronatkins

Using the option setter clears other configured options.

packrat::set_opts(ignored.packages = c("emo"), persist = FALSE)
packrat::opts$snapshot.recommended.packages(TRUE, persist = FALSE)
packrat::get_opts(c("ignored.packages"))
# => NULL

This is using the setter defined by:

packrat/R/options.R

Lines 173 to 179 in c648ce2

make_setter <- function(name) {
force(name)
function(x, persist = TRUE) {
if (missing(x)) return(get_opts(name))
else setOptions(setNames(list(x), name), persist = persist)
}
}

the setter is connected to the packrat::opts here:

packrat/R/options.R

Lines 221 to 223 in c648ce2

opts <- setNames(lapply(names(VALID_OPTIONS), function(x) {
make_setter(x)
}), names(VALID_OPTIONS))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions