pak icon indicating copy to clipboard operation
pak copied to clipboard

write output from package build failure

Open kevinushey opened this issue 2 years ago • 2 comments

I saw the following when installing devtools on an Ubuntu 22.04 VM:

> pak::pkg_install("devtools")
 
→ Will install 71 packages.
→ Will download 71 CRAN packages (23.14 MB).
+ askpass       1.1    [bld][cmp][dl] (5.73 kB)
+ brew          1.0-7  [bld][dl] (55.52 kB)
< ... >  
ℹ Building gert 1.6.0                              
x Failed to build gert 1.6.0                       
Error: Failed to build source package 'gert'       
Type .Last.error.trace to see where the error occurred
> .Last.error.trace

 Stack trace:

Warning: partial match of 'topenv' to 'topenvs'
 12. (function (...)  ...
 13. base:::withCallingHandlers(cli_message = function(msg) { ...
 14. get("pkg_install_do_plan", asNamespace("pak"))(...)
 15. pkgdepends::install_package_plan(plan = plan, lib = lib, num_workers = num_ ...
 16. base:::withCallingHandlers({ ...
 17. pkgdepends:::handle_events(state, events)
 18. pkgdepends:::handle_event(state, i)
 19. pkgdepends:::stop_task(state, worker)
 20. pkgdepends:::stop_task_build(state, worker)
 21. base:::throw(new_pkg_build_error("Failed to build source package {pkg}",  ...
 22. base:::signalCondition(cond)
 23. (function (e)  ...
 24. base:::stop(e)
 25. (function (e)  ...

 x Failed to build source package 'gert' 

Compare to a plain install.packages() invocation:

> install.packages("gert")
Installing package into '/home/kevin/R/aarch64-unknown-linux-gnu-library/4.1'
(as 'lib' is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/gert_1.6.0.tar.gz'
Content type 'application/x-gzip' length 117915 bytes (115 KB)
==================================================
downloaded 115 KB

* installing *source* package ‘gert’ ...
** package ‘gert’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lgit2
----------------------------- ANTICONF -------------------------------
Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.
----------------------------------------------------------------------
ERROR: configuration failed for package ‘gert’
* removing ‘/home/kevin/R/aarch64-unknown-linux-gnu-library/4.1/gert’
* restoring previous ‘/home/kevin/R/aarch64-unknown-linux-gnu-library/4.1/gert’
Warning in install.packages("gert") :
  installation of package 'gert' had non-zero exit status

It would be helpful if pak echoed the output from the configure script here.

> packageVersion("pak")
[1] '0.3.0'

kevinushey avatar May 23 '22 18:05 kevinushey

Type .Last.error, that souls show the error.

gaborcsardi avatar May 23 '22 19:05 gaborcsardi

Thanks, you're right:

> pak::pkg_install("gert")
 
→ Will install 1 package.
→ The package (117.92 kB) is cached.
+ gert   1.6.0 [bld][cmp]
ℹ No downloads are needed, 1 pkg (117.92 kB) is cached
ℹ Building gert 1.6.0
x Failed to build gert 1.6.0                                
Error: Failed to build source package 'gert'                
Type .Last.error.trace to see where the error occurred
> .Last.error
<callr_remote_error: Failed to build source package 'gert'>
 in process 120676 
-->
Failed to build source package 'gert', stdout + stderr:

OE> * installing *source* package ‘gert’ ...
OE> ** package ‘gert’ successfully unpacked and MD5 sums checked
OE> staged installation is only possible with locking
OE> ** using non-staged installation
OE> Using PKG_CFLAGS=
OE> Using PKG_LIBS=-lgit2
OE> ----------------------------- ANTICONF -------------------------------
OE> Configuration failed to find libgit2 library. Try installing:
OE>  * brew: libgit2 (MacOS)
OE>  * deb: libgit2-dev (Debian, Ubuntu, etc)
OE>  * rpm: libgit2-devel (Fedora, CentOS, RHEL)
OE> If libgit2 is already installed, check that 'pkg-config' is in your
OE> PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
OE> is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
OE> R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
OE> -------------------------- [ERROR MESSAGE] ---------------------------
OE> <stdin>:1:10:fatal error: git2.h: No such file or directory
OE> compilation terminated.
OE> ----------------------------------------------------------------------
OE> ERROR: configuration failed for package ‘gert’
OE> * removing ‘/tmp/RtmpjpG1VO/pkg-lib1d7647e04a691/gert’

Should pak include that as part of the output? That is, instead of just:

Type .Last.error.trace to see where the error occurred

pak could also print:

Type .Last.error to print the last error
Type .Last.error.trace to see where the error occurred

kevinushey avatar May 23 '22 19:05 kevinushey

The error now includes the trace, I believe.

gaborcsardi avatar Nov 01 '23 13:11 gaborcsardi