Open agilly opened 6 days ago
The default policy is to always install the latest versions of the packages specified directly, and the most convenient versions of the dependencies. So
pak::pkg_install("imager")
will always try to install the latest version of imager.
One way to work around it is to use the any::
(virtual) package source, which will default to the most convenient version:
pak::pkg_install("any::imager")
→ Will install 1 package.
→ Will download 1 CRAN package (9.12 MB).
+ imager 0.45.8 [dl] (9.12 MB)
ℹ Getting 1 pkg (9.12 MB)
✔ Got imager 0.45.8 (x86_64-w64-mingw32) (9.12 MB)
✔ Downloaded 1 package (9.12 MB) in 1.7s
✔ Installed imager 0.45.8 (371ms)
✔ 1 pkg + 21 deps: kept 12, added 1, dld 1 (9.12 MB) [3.6s]
Thanks for the prompt reply, that solves it. I was looking at the FAQ of V 0.7.2, and it does suggest that pak will choose a binary over a source even if the latter is more recent, although rereading that section it does say that this behavior is only for dependencies of packages to be installed.
From the FAQ:
Sometimes it is sufficient to install the binary package of an older version of a dependency, instead of the newer source package that potentially needs compilers, system tools or libraries. pkg_install() and lockfile_create() default to upgrade = FALSE, which always chooses binaries over source packages, so if you use pkg_install() you don’t need to do anything extra. The localinstall* functions default to upgrade = TRUE, as does pak() with pkg = NULL, so for these you need to explicitly use upgrade = FALSE.
I agree that the behavior can be deduced, but it may be good to state somewhere explicitly that if the latest version of a package exists only as a source, the source will be chosen over the binary, along with the above method to override that behavior. I am guessing that R deployments without Rtools on Windows are not entirely uncommon, and this may be helpful?
Just a suggestion & food for thought. Thanks for solving the issue.
If you don't mind, I'll leave this open until the docs are fixed.
Possibly related to #613.
I see an installation error when trying to install
imager
on R for Windows 4.2.0 (note: in my setting it is difficult to upgrade R otherwise I would).The result of install.packages:
I can use the package successfully after this. However, my setup stack uses pak to install missing packages. I successfully install pak 0.7.2:
However, when I ask it for imager:
Note the
[bld][cmp][dl]
next to imager in the list. I thought from the help page that even if a source exists and is newer than the binary (the case for imager) it will default to the binary. However here it seems to try and build the source. For the same admin reasons as above it is not practical for me to install Rtools. Is this a bug?I can circumvent the whole thing by forcing the download of the binary:
which gives:
However, this feels clumsy. Any thoughts?