r-lib / pak

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

Improve error message #578

Closed grst closed 2 months ago

grst commented 6 months ago

I had an issue with installing limma: one of the dependencies could not be loaded because a required system library could not be found.

Unfortunately, pak's error message doesn't tell me so:

> pak::pkg_install("limma")

→ Will install 2 packages.
→ All 2 packages (0 B) are cached.
+ limma     3.58.1 [bld][cmp]
+ statmod   1.5.0
ℹ No downloads are needed, 2 pkgs are cached
✔ Got statmod 1.5.0 (x86_64-pc-linux-gnu-rhel-8.8) (342.03 kB)
✔ Installed statmod 1.5.0  (1.8s)
ℹ Building limma 3.58.1
✖ Failed to build limma 3.58.1
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package limma.
Type .Last.error to see the more details.

> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package limma.
---
Backtrace:
1. pak::pkg_install("limma")
2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("pkg_install_do_plan", asNamespace("pak"))(...)
 3. proposal$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(pkg_error("Failed to build source package {.pkg {pkg}}.", …
11. | base::signalCondition(cond)
12. global (function (e) …

Compared to BiocManager::install which points this out immediately:

> BiocManager::install("limma")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
    CRAN: https://packagemanager.rstudio.com/all/__linux__/centos7/latest
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.2 (2023-10-31)
Installing package(s) 'BiocVersion', 'limma'
trying URL 'https://bioconductor.org/packages/3.18/bioc/src/contrib/BiocVersion_3.18.1.tar.gz'
Content type 'application/x-gzip' length 973 bytes
==================================================
downloaded 973 bytes

trying URL 'https://bioconductor.org/packages/3.18/bioc/src/contrib/limma_3.58.1.tar.gz'
Content type 'application/x-gzip' length 2804950 bytes (2.7 MB)
==================================================
downloaded 2.7 MB

* installing *source* package ‘BiocVersion’ ...
** using staged installation
** help
*** installing help indices
  converting help for package ‘BiocVersion’
    finding HTML links ... done
    BiocVersion-pkg                         html
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (BiocVersion)
* installing *source* package ‘limma’ ...
** using staged installation
** libs
using C compiler: ‘gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20)’
gcc -I"/opt/R/4.3.2/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -g -O2  -c init.c -o init.o
gcc -I"/opt/R/4.3.2/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -g -O2  -c normexp.c -o normexp.o
gcc -I"/opt/R/4.3.2/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -g -O2  -c weighted_lowess.c -o weighted_lowess.o
gcc -shared -L/opt/R/4.3.2/lib/R/lib -L/usr/local/lib -o limma.so init.o normexp.o weighted_lowess.o -L/opt/R/4.3.2/lib/R/lib -lR
installing to /home/jenkins/R/4.3.2/library/00LOCK-limma/00new/limma/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/home/jenkins/R/4.3.2/library/statmod/libs/statmod.so':
  libgfortran.so.3: cannot open shared object file: No such file or directory
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘limma’
* removing ‘/home/jenkins/R/4.3.2/library/limma’

The downloaded source packages are in
        ‘/tmp/RtmpS30mij/downloaded_packages’
Installation paths not writeable, unable to update packages
  path: /opt/R/4.3.2/lib/R/library
  packages:
    cluster, foreign, lattice, Matrix, mgcv, nlme, rpart
Warning message:
In install.packages(...) :
  installation of package ‘limma’ had non-zero exit status

Sitrep

> pak::pak_sitrep()
* pak version:
- 0.7.1
* Version information:
- pak platform: x86_64-pc-linux-musl (current: x86_64-pc-linux-gnu, compatible)
- pak repository: - (local install?)
* Optional packages missing:
- pillar
* Library path:
- /home/jenkins/R/4.3.2/library
- /opt/R/4.3.2/lib/R/library
* pak is installed at /home/jenkins/R/4.3.2/library/pak.
* Dependency versions:
- callr      3.7.3
- cli        3.6.1.9000
- curl       5.2.0
- desc       1.4.3
- filelock   1.0.2
- jsonlite   1.8.8
- lpSolve    5.6.20
- pkgbuild   1.4.3
- pkgcache   2.2.1
- pkgdepends 0.7.0.9000
- pkgsearch  3.1.3
- processx   3.8.3
- ps         1.7.5
- R6         2.5.1
- zip        2.3.0
* Dependencies can be loaded
latot commented 2 months ago

Hi, I would appreciate if this gets an improvement, I'm having hard time debuuging an app that refuses to install with pak, while it works with remotes, but can't know which are the errors behind... because it only fails with pak.

Thx!

gaborcsardi commented 2 months ago

This is already fixed, try the nightly devel build from https://pak.r-lib.org/reference/install.html#nightly-builds

latot commented 2 months ago

@gaborcsardi yay thx! I'll check it... in two days, and I'll tell you how it went :)