r-lib / pak

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

Unclear error when source install fails #266

Open jeroen opened 3 years ago

jeroen commented 3 years ago
> pak::pkg_install('magick')
⠋ Updating metadata [0/6] | Downloading [0 B / 0 B]                       
 Found  Updating local metadata database ... done                               

→ Will install 4 packages.
→ Will download 4 CRAN packages (8.70 MB).
+ Rcpp       1.0.6 [bld][cmp][dl] (2.95 MB)
+ curl       4.3   [bld][cmp][dl] (673.78 kB)
+ magick     2.6.0 [bld][cmp][dl] (4.81 MB)
+ magrittr   2.0.1 [bld][cmp][dl] (265.58 kB)
ℹ Getting 4 pkgs (8.70 MB)

 1.6 MB/s ✓ Got curl 4.3 (source) (673.78 kB)                                             
                                                                      ✓        

 4.9 MB/s ✓ Downloaded 4 packages (8.70 MB) in 1.8s                             
ℹ Building curl 4.3
ℹ Building magrittr 2.0.1
ℹ Building Rcpp 1.0.6
✓ Built magrittr 2.0.1 (3s)                                                
✓ Installed magrittr 2.0.1  (48ms)                                        
✓ Built curl 4.3 (6s)                                            
✓ Installed curl 4.3  (73ms)                                                
✓ Built Rcpp 1.0.6 (38.8s)                                                 
✓ Installed Rcpp 1.0.6  (136ms)                              
ℹ Building magick 2.6.0                                      
x Failed to build magick 2.6.0 (941ms)                       
Error: Failed to build source package 'magick'               
Type .Last.error.trace to see where the error occured
jimhester commented 3 years ago

This is a duplicate of https://github.com/r-lib/pak/issues/207 and only occurs iteractively.

If you use .Last.error you can see the full error as a workaround.

gaborcsardi commented 3 years ago

This is a bit different, because the error that pak (pkgcache probably) throws is not very informative:

> pak::pak("magick")
v Updated metadata: 0 B in 6 files.
i source packages are missing from CRAN and Bioconductor
v Updating local metadata database ... done
Error: Cannot install packages:
* magick: Can't subset columns that don't exist.
x Columns `license` and `md5sum` don't exist.
Type .Last.error.trace to see where the error occured
> .Last.error
<callr_remote_error: Cannot install packages:
* magick: Can't subset columns that don't exist.
x Columns `license` and `md5sum` don't exist.>
 in process 4681
-->
<simpleError: Cannot install packages:
* magick: Can't subset columns that don't exist.
x Columns `license` and `md5sum` don't exist.>

Or you might get a slightly different one, if GitHub fails first, but that's bad as well:

> pak::pak("jeroen/magick")
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Error: Cannot install packages:
* jeroen/magick: Cannot query GitHub, are you offline?
Type .Last.error.trace to see where the error occured
> .Last.error
<callr_remote_error: Cannot install packages:
* jeroen/magick: Cannot query GitHub, are you offline?>
 in process 4681
-->
<simpleError: Cannot install packages:
* jeroen/magick: Cannot query GitHub, are you offline?>
ColinFay commented 1 year ago

+1 on this, another example of an error that is not clear even with .Last.error:

> pak::pak("sodium")

→ Will install 1 package.
→ The package (468.06 kB) is cached.
+ sodium   1.2.1 [bld][cmp]
ℹ No downloads are needed, 1 pkg (468.06 kB) is cached
ℹ Building sodium 1.2.1
✖ Failed to build sodium 1.2.1                               
Error:                                                       
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package 'sodium'
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 'sodium'
---
Backtrace:
1. pak::pak("sodium")
2. pak::pkg_install(pkg, ...)
3. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
4. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("pkg_install_do_plan", asNamespace("pak"))(...)
 3. pkgdepends::install_package_plan(plan = plan, lib = lib, num_workers = num_workers)
 4. base::withCallingHandlers({ …
 5. pkgdepends:::handle_events(state, events)
 6. pkgdepends:::handle_event(state, i)
 7. pkgdepends:::stop_task(state, worker)
 8. pkgdepends:::stop_task_build(state, worker)
 9. base::throw(new_pkg_build_error("Failed to build source package {pkg}", …
10. | base::signalCondition(cond)
11. global (function (e) …

Whereas the error with install.packages() is way more informative:

> install.packages("sodium")
trying URL 'https://cloud.r-project.org/src/contrib/sodium_1.2.1.tar.gz'
Content type 'application/x-gzip' length 468055 bytes (457 KB)
==================================================
downloaded 457 KB

* installing *source* package ‘sodium’ ...
** package ‘sodium’ successfully unpacked and MD5 sums checked
** using staged installation
Package libsodium was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsodium.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsodium' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lsodium
--------------------------- [ANTICONF] --------------------------------
Configuration failed because libsodium was not found. Try installing:
 * deb: libsodium-dev (Debian, Ubuntu, etc)
 * rpm: libsodium-devel (Fedora, EPEL)
 * csw: libsodium_dev (Solaris)
 * brew: libsodium (OSX)
If libsodium is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libsodium.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: sodium.h: No such file or directory
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘sodium’
* removing ‘/home/ubuntu/lib/R/library/sodium’

The downloaded source packages are in
        ‘/tmp/RtmpGJif7E/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("sodium") :
  installation of package ‘sodium’ had non-zero exit status
gaborcsardi commented 1 year ago

@ColinFay what version of pak?

schloerke commented 1 year ago

I had similar not-clear ! Failed to build source package 'PKG' error messages (Full description in #453).

(It was caused by {purrr} not being loaded properly on windows (tidyverse/purrr#103). {purrr} v1.0.1 was put on CRAN 2023-01-10. The fixed binaries should be built soon.)

rvalieris commented 5 months ago

same issue here with pak 0.7.2

the problem is that .Last.error is a callr_status_error, the actual error is in .Last.error$parent and when you print that the issue is obvious, here I hit the error because a system library necessary by the package (units) was missing:

r$> .Last.error$parent
! Failed to build source package units., stdout + stderr (last 10 lines):

OE>     --configure-args='--with-udunits2-lib=/usr/local/lib'
OE>   if the library was not found, and/or:
OE>     --configure-args='--with-udunits2-include=/usr/include/udunits2'
OE>   if the header was not found, replacing paths with appropriate values.
OE>   You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
OE> --------------------------------------------------------------------------------
OE>
OE> See `config.log' for more details
OE> ERROR: configuration failed for package ‘units’
OE> * removing ‘/tmp/Rtmp3ygDQS/pkg-libfae66d85d295/units’
gaborcsardi commented 5 months ago

This should be fixed in the dev version of pak.

johnyaku commented 4 months ago

This should be fixed in the dev version of pak.

In case anybody else is wondering how to install the dev version: https://pak.r-lib.org/reference/install.html#stable-rc-and-devel-streams