Skip to content

Commit

Permalink
Fix attaching usethis is lib path has changed
Browse files Browse the repository at this point in the history
If the lib path has changed since loading usethis,
.onAttach potentially fails when it tries to attach
usethis as the new lib path might contain a different
usethis version.

Closes r-lib#1987.
  • Loading branch information
gaborcsardi authored and jimhester committed Feb 15, 2019
1 parent e4e57aa commit 188a613
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ devtools_default_options <- list(
.onAttach <- function(libname, pkgname) {
env <- as.environment(paste0("package:", pkgname))
env[[".conflicts.OK"]] <- TRUE
suppressPackageStartupMessages((get("library", baseenv()))("usethis"))
usethis_lib <- dirname(getNamespaceInfo("usethis", "path"))
suppressPackageStartupMessages((
get("library", baseenv()))("usethis", lib.loc = usethis_lib))
}

0 comments on commit 188a613

Please sign in to comment.