Skip to content

Use pak::local_install_deps() in install()#2651

Merged
hadley merged 13 commits intomainfrom
pak-local-install-deps
Feb 12, 2026
Merged

Use pak::local_install_deps() in install()#2651
hadley merged 13 commits intomainfrom
pak-local-install-deps

Conversation

@hadley
Copy link
Member

@hadley hadley commented Jan 22, 2026

Includes some general updates to the docs of install(), and mild improvements to non-quiet output.

Fixes #2486. Fixes #2572.

@jennybc if you're testing install() interactively, it doesn't work on devtools itself, for probably obvious reasons.

Includes some general updates to the docs of `install()`, and mild improvements to non-quiet output.

Fixes #2486. Fixes #2572.
@hadley hadley requested a review from jennybc January 22, 2026 15:32
build_opts <- c("--no-resave-data", "--no-manual")
# Install dependencies
local({
if (quiet) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hack around lack of quiet argument or option for pak.

if (build) {
install_path <- pkgbuild::build(
pkg$path,
build = build,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit hard to see in the diff, but we're no longer passing any build or install options when we install the dependencies. I think this is likely to be fine, since you'd generally except these to coming from CRAN and not built locally.

@hadley
Copy link
Member Author

hadley commented Jan 30, 2026

After this change, Positron should probably revert to calling devtools::install(), rather than pak::local_install(upgrade = FALSE).

Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hadley I took this a bit further and left some inline comments. What do you think? I'm happy for merge.

  • Improved output headers to include the package name and distinguish the three phases: "Installing dependencies of {pkg}", "Building {pkg}" (only when build = TRUE), "Installing {pkg}"
  • Changed keep_source default to getOption("keep.source.pkgs") || !build, so install(quick = TRUE) and install(build = FALSE) automatically preserve working source references
  • Refined docs for quick, build, and keep_source to be more accurate and have less overlap

Comment on lines +13 to +15
#' @param quick if `TRUE`, skips some optional steps (e.g. help
#' pre-rendering and multi-arch builds) to make installation as fast
#' as possible.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clarified this and had to do some research! I've never understood what it meant to "skip docs", because clearly help files are available after installation even with install(quick = TRUE). So I've reworded to be more clear about what --no-docs actually does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

dependencies = NA,
upgrade = FALSE,
build_vignettes = FALSE,
keep_source = getOption("keep.source.pkgs") || !build,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually changed this default!

The previous default didn't make much sense to me, as it made it pretty hard for a developer to get srcrefs. You had to know to do build = FALSE AND keep_source = TRUE.

I think this default is going to make default behaviour much more sensible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask why we don't default to keep_source = TRUE but reading the documentation made it clear 😄.

R/install.R Outdated

if (build) {
if (!quiet) {
cli::cat_rule(paste0("Building ", pkg$package), col = "cyan")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this header so it would be more obvious whether the build step is happening or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this again, and added a snapshot test to hopefully illustrate why.

Comment on lines +13 to +15
#' @param quick if `TRUE`, skips some optional steps (e.g. help
#' pre-rendering and multi-arch builds) to make installation as fast
#' as possible.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

dependencies = NA,
upgrade = FALSE,
build_vignettes = FALSE,
keep_source = getOption("keep.source.pkgs") || !build,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask why we don't default to keep_source = TRUE but reading the documentation made it clear 😄.

Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the headers that stated the name of the package we are install()ing, but it's not a hill I will die on. You seem to like without and that's OK too.

@hadley hadley merged commit f023fb2 into main Feb 12, 2026
14 checks passed
@hadley hadley deleted the pak-local-install-deps branch February 12, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import pak Why is install() so keen to update packages?

2 participants