pak icon indicating copy to clipboard operation
pak copied to clipboard

Optionally install existing binary version if source is newer?

Open hadley opened this issue 2 years ago • 16 comments

This is most important for mac where it may take multiple days to build a binary version.

hadley avatar Sep 15 '21 19:09 hadley

pak::pkg_install() already chooses the binary, unless you specify upgrade = TRUE. But I guess you want something like "upgrade, but only use the binaries"?

gaborcsardi avatar Sep 15 '21 19:09 gaborcsardi

Yeah, whatever is causing https://github.com/r-lib/testthat/runs/3613526651 to fail

hadley avatar Sep 15 '21 20:09 hadley

pak::pkg_install("RMariaDB", upgrade = FALSE) still attempts to build the package: on arm64 the currently available binary is 1.2.0 . How can I enforce installation from binary?

krlmlr avatar Dec 22 '21 14:12 krlmlr

Directly specified packages are always updated, except if you use any::. So this works:

pak::pkg_install("any::RMariaDB", upgrade = FALSE)

The only catch is that any:: requires a newer dev version of pak, and our repo does not have a binary. So you would need to install pak from GH, and then create an embedded library with pak:::create_dev_lib().

Unfortunately we can't update the M1 binaries daily because there is no CI for that.

gaborcsardi avatar Dec 22 '21 17:12 gaborcsardi

Would it make sense to respect pkgType option (i.e., use type = getOption("pkgType")) like in utils::install.packages() and remotes::install_*()? We could then use something like:

          options(
            install.packages.check.source = "no",
            pkgType = ifelse(grepl("linux", R.version$os), "source", "binary")
          )

This works well with the other package installers. It fixes GHA failures when a dependency that needs compilation would fail until binaries are built from the latest source, specifically on macOS and Windows.

hsbadr avatar Jan 15 '22 14:01 hsbadr

This works well with the other package installers.

Except that if some package does require the newer source version, then it fails. This is not an uncommon situation.

This is not an issue any more on GHA with the new r-lib/actions@v2 versions of the actions. If it fails for you, please open an issue in the r-lib/actions@v2 respository.

gaborcsardi avatar Jan 15 '22 17:01 gaborcsardi

Except that if some package does require the newer source version, then it fails. This is not an uncommon situation.

True. That's why I install the versioned dependencies with type = "source".

This is not an issue any more on GHA with the new r-lib/actions@v2 versions of the actions. If it fails for you, please open an issue in the r-lib/actions@v2 respository.

It did fail on January 13-14 due to an Rcpp update that didn't have the binaries for macOS built, and the package installation from source failed.

hsbadr avatar Jan 15 '22 17:01 hsbadr

It did fail on January 13-14 due to an Rcpp update that didn't have the binaries for macOS built, and the package installation from source failed.

Can you show a GHA job?

gaborcsardi avatar Jan 15 '22 18:01 gaborcsardi

Can you show a GHA job?

I've switched to remotes for now, but here's the setup-r-dependencies step that I was using:

      - name: Set up R dependencies
        uses: r-lib/actions/setup-r-dependencies@master
        with:
          cache-version: 1
          extra-packages: covr, curl, devtools, htmltools, lintr, pkgdown, rcmdcheck, rmarkdown, roxygen2, sessioninfo, styler
          needs: |
            website
            coverage
          pak-version: 'devel'
          working-directory: '.'

which is replaced by:

      - name: Install R dependencies
        run: |
          options(
            crayon.enabled = TRUE,
            install.packages.check.source = "no",
            pkgType = ifelse(grepl("linux", R.version$os), "source", "binary")
          )
          install.packages("remotes")
          remotes::install_cran("covr")
          remotes::install_cran("curl")
          remotes::install_cran("devtools")
          remotes::install_cran("htmltools")
          remotes::install_cran("lintr")
          remotes::install_cran("mgcv", type = "source")
          remotes::install_cran("parsnip", type = "source")
          remotes::install_cran("pkgdown")
          remotes::install_cran("rcmdcheck")
          remotes::install_cran("rmarkdown")
          remotes::install_cran("roxygen2")
          remotes::install_cran("sessioninfo")
          remotes::install_cran("styler")
          remotes::install_deps(dependencies = TRUE)
          remotes::install_local(".")
        shell: Rscript {0}

Note that the versioned dependencies are installed with type = "source". The later works in all conditions; but, unfortunately, it's specific to the package, not universal like r-lib/actions/setup-r-dependencies.

hsbadr avatar Jan 15 '22 19:01 hsbadr

I am sorry, I meant an actual run on GHA.

gaborcsardi avatar Jan 15 '22 19:01 gaborcsardi

FWIW this is how the setup-r-dependencies action is best used: https://github.com/r-lib/actions/blob/fc2c753b84e3c8458c8d7a27431b860601b3b559/examples/check-full.yaml#L54-L57

In particular,

  • use the v2 tag, and not master: https://github.com/r-lib/actions#releases-and-tags
  • do not use pak-version: 'devel', while it is the default currently, it won't be in the future
  • extra packages from CRAN are best with an any:: prefix: https://github.com/r-lib/actions/tree/v2-branch/setup-r-dependencies#extra-packages-and-the-any-prefix

gaborcsardi avatar Jan 15 '22 19:01 gaborcsardi

  • extra packages from CRAN are best with an any:: prefix: https://github.com/r-lib/actions/tree/v2-branch/setup-r-dependencies#extra-packages-and-the-any-prefix

Yeah, I got an error when I added the any:: prefix, but maybe b/c I was using the master branch not v2 tag (or earlier before I added pak-version: 'devel'; https://github.com/r-lib/pak/issues/318#issuecomment-999731467). I'll test that again and open an issue in r-lib/actions if I run into this problem. Thanks for the information!

hsbadr avatar Jan 15 '22 19:01 hsbadr

@gaborcsardi I've followed your suggestions and now I get an error in #358.

Here's the GHA run: https://github.com/hsbadr/additive/runs/4828585746

hsbadr avatar Jan 15 '22 20:01 hsbadr

#358 is hopefully fixed, so your workflow should work now.

gaborcsardi avatar Jan 16 '22 02:01 gaborcsardi

#358 is hopefully fixed, so your workflow should work now.

Ok; thanks! I'll test it and report back.

hsbadr avatar Jan 16 '22 04:01 hsbadr

#358 is hopefully fixed, so your workflow should work now.

Confirmed. Thanks!

hsbadr avatar Jan 16 '22 05:01 hsbadr