Temporarily change the system search path.
Usage
with_path(new, code, action = c("prefix", "suffix", "replace"))
local_path(
new = list(),
action = c("prefix", "suffix", "replace"),
.local_envir = parent.frame()
)See also
withr for examples
Examples
# temporarily modify the system PATH, *prefixing* the current path
with_path(getwd(), Sys.getenv("PATH"))
#> [1] "/tmp/.tmp7S8S1R/docs/withr/3.0.3/src/docs/reference:/home/runner/.TinyTeX/bin/x86_64-linux:/home/runner/work/_temp/raybuilder:/opt/hostedtoolcache/Python/3.12.13/x64/bin:/opt/hostedtoolcache/Python/3.12.13/x64:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
# temporarily modify the system PATH, *appending* to the current path
with_path(getwd(), Sys.getenv("PATH"), "suffix")
#> [1] "/home/runner/.TinyTeX/bin/x86_64-linux:/home/runner/work/_temp/raybuilder:/opt/hostedtoolcache/Python/3.12.13/x64/bin:/opt/hostedtoolcache/Python/3.12.13/x64:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/games:/snap/bin:/tmp/.tmp7S8S1R/docs/withr/3.0.3/src/docs/reference"
