r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
671 stars 60 forks source link

Is `{pak}` downloading unnecessary deps? #452

Closed IndrajeetPatil closed 1 year ago

IndrajeetPatil commented 1 year ago

I see workflow failures only on macOS because a dependency can't be successfully downloaded.

Build failure log

✖ Failed to build RcppGSL 0.3.12
  Error: 
  ! error in pak subprocess
  Caused by error in `stop_task_build(state, worker)`:
  ! Failed to build source package 'RcppGSL'
  ---
  Backtrace:
  1. pak::lockfile_install(".github/pkg.lock")
  2. pak:::remote(function(...) { …
  3. err$throw(res$error)
  ---
  Subprocess backtrace:
   1. base::withCallingHandlers(cli_message = function(msg) { …
   2. get("lockfile_install_internal", asNamespace("pak"))(...)
   3. plan$install()
   4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
   5. base::withCallingHandlers({ …
   6. pkgdepends:::handle_events(state, events)
   7. pkgdepends:::handle_event(state, i)
   8. pkgdepends:::stop_task(state, worker)
   9. pkgdepends:::stop_task_build(state, worker)
  10. base::throw(new_pkg_build_error("Failed to build source package {pkg}", …
  11. | base::signalCondition(cond)
  12. global (function (e) …

But, as {pak} itself reveals, {statsExpressions} doesn't rely on {RcppGSL}, through any of its weak or strong dependencies:

> pak::pkg_deps_explain("statsExpressions", "RcppGSL", dependencies = "all")
✔ Loading metadata database ... done
x RcppGSL 

So I am not sure why this dependency is needed here. Is this a bug in {pak}?

P.S. Note that I am using devel version of {pak} in the workflow.

gaborcsardi commented 1 year ago

But, as {pak} itself reveals, {statsExpressions} doesn't rely on {RcppGSL}, through any of its weak or strong dependencies:

It does when some dependencies need to be installed from source:

❯ PKG_PLATFORMS=source R -q
❯ pak::pkg_deps_explain("IndrajeetPatil/statsExpressions@strict_windows", "RcppGSL", dependencies = TRUE)
statsExpressions -> metaplus -> Rfast -> RcppZiggurat -> RcppGSL
IndrajeetPatil commented 1 year ago

Ah, I see. Thanks for the clarification.

Is there any way to avoid {RcppGSL} download failure on macOS in GHA workflow?

gaborcsardi commented 1 year ago

It is not a download failure, it is a build failure. You probably need to install GSL to build it from source: https://github.com/cran/RcppGSL/blob/9674943f5f483dd8f53ed471bd6598a5413f903e/DESCRIPTION#L24

gaborcsardi commented 1 year ago

I am not sure why it is built from source, though.

gaborcsardi commented 1 year ago

Oh, because you are using R-devel, and CRAN does not have macOS binaries for R-devel.

IndrajeetPatil commented 1 year ago

It is not a download failure, it is a build failure. You probably need to install GSL to build it from source: https://github.com/cran/RcppGSL/blob/9674943f5f483dd8f53ed471bd6598a5413f903e/DESCRIPTION#L24

I will try this.

Oh, because you are using R-devel, and CRAN does not have macOS binaries for R-devel.

Ah, I see. I will use the R-release version for macOS then.

Thanks a lot, Gabor!!