pak
pak copied to clipboard
Suggests dependencies aren't included if package already installed
If a package has already been installed, attempting to install it again with a broader set of dependencies has no effect. One would expect that the additional dependencies would be installed.
pak::pak("<remote>") # installs package and hard dependencies
pak::pak("<remote>", dependencies = TRUE) # will not install new dependencies if package is already installed
Example
Using https://github.com/ddsjoberg/gtsummary as an example, which takes two remote dependencies:
Remotes:
github::insightsengineering/cards, # Imports dependency
github::insightsengineering/cardx # Suggests dependency
Installing with pak::pak("ddsjoberg/gtsummary@518be7d8"), as expected cards gets installed, but not cardx
> pak::pak("ddsjoberg/gtsummary@518be7d8")
→ Will install 17 packages.
+ cards 0.1.0.9046 [bld][cmp] (GitHub: b890c25)
Then attempting to install with suggested dependencies using pak::pak("ddsjoberg/gtsummary@518be7d8", dependencies = TRUE)
> pak::pak("ddsjoberg/gtsummary@518be7d8", dependencies = TRUE)
✔ All system requirements are already installed.
ℹ No downloads are needed
✔ 1 pkg + 62 deps: kept 62 [3.7s]
However, if I remove.packages("gtsummary") and try again:
> pak::pak("ddsjoberg/gtsummary@518be7d8", dependencies = TRUE)
→ Will install 82 packages.
→ Will download 51 CRAN packages (48.07 MB), cached: 31 (28.86 MB).
+ cardx 0.1.0.9067 [bld][cmp] (GitHub: 738e4e4)
I don't really understand the example, cardx is a hard dependency AFAICT:
❯ pak::pkg_deps_tree("ddsjoberg/gtsummary")
ddsjoberg/gtsummary 1.9.9.9006 ✨👷🏿♂️🔧
├─github::insightsengineering/cards 0.1.0.9046 ✨👷🏿♂️🔧
...
├─github::insightsengineering/cardx 0.1.0.9067 ✨👷🏿♂️🔧
│ ├─github::insightsengineering/cards
...
But here is a simpler reprex:
pak::pkg_remove("testthat")
pak::pkg_remove("fs")
pak::pkg_install("fs", dependencies=TRUE)
→ Will install 2 packages.
→ All 2 packages (3.67 MB) are cached.
+ fs 1.6.4
+ testthat 3.2.1.1
ℹ No downloads are needed, 2 pkgs (3.67 MB) are cached
✔ Got fs 1.6.4 (aarch64-apple-darwin20) (625.52 kB)
✔ Got testthat 3.2.1.1 (aarch64-apple-darwin20) (3.06 MB)
✔ Installed fs 1.6.4 (37ms)
✔ Installed testthat 3.2.1.1 (44ms)
✔ 1 pkg + 60 deps: kept 59, added 2, dld 2 (3.69 MB) [2.7s]
pak::pkg_remove("testthat")
pak::pkg_install("fs", dependencies=TRUE)
ℹ No downloads are needed
✔ 1 pkg: kept 1 [549ms]
I had to do a double take because I was sure it was a Suggests dependency, but didn't go out and confirm. I was just chatting with the maintainer which prompted the bug report, and it looks like they made a commit to bump it to Imports to skirt this issue for now.
Thanks for continuing to investigate and following up with a more reproducible example. I'll add commit hashes to the original examples.