r-minimal icon indicating copy to clipboard operation
r-minimal copied to clipboard

Compile output of R packages being installed with installr

Open Danoontjes opened this issue 2 years ago • 1 comments

Hi,

Is there a convenient way to display the compile output on R packages being installed with installr? I have a package that fails compilation, but it's hard to find out why it fails. It doesn't look like installr has a switch to enable output.

Usage: /usr/local/bin/installr [ -c | -d ] [ -a pkgs ] [ -t pkgs ] [ -r ] [ -p ] REMOTES ...

Options:
  -c    install C and C++ compilers and keep them
  -d    install C and C++ compilers, temporarily
  -a    install Alpine packages and keep them
  -t    install Alpine packages, temporarily
  -p    do not remove pak after the installation (ignored if -r is given).

REMOTES may be:
  * package names from CRAN/Bioconductor, e.g.    ggplot2
  * slugs of GitHub repos, e.g.                   tidyverse/ggplot2
  * GitHub branch, tag or commit, e.g             tidyverse/[email protected]
  * URLs to package .tar.gz files, e.g.           url::https://x.com/pkg.tar.gz
  * path to a local directory, e.g.               local::.

Danoontjes avatar Oct 25 '22 09:10 Danoontjes

It is a bug in the devel version of r-lib/pak. Here is a way to see the error. Install the compilers first:

installr -c

The install the stable version of pak from R:

install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))

Then install the package(s) you want, with pak (or install.packages() if they are CRAN packages), from R, and type .Last.error after the compilation error. For example:

> pak::pkg_install("ps")
✔ Loading metadata database ... done

→ Will install 1 package.
→ The package (128.66 kB) is cached.
+ ps   1.7.1 [bld][cmp]
ℹ No downloads are needed, 1 pkg (128.66 kB) is cached
ℹ Building ps 1.7.1
✖ Failed to build ps 1.7.1
Error: Failed to build source package 'ps'
Type .Last.error.trace to see where the error occurred
> .Last.error
<callr_remote_error: Failed to build source package 'ps'>
 in process 784
-->
Failed to build source package 'ps', stdout + stderr:

OE> * installing *source* package ‘ps’ ...
OE> ** package ‘ps’ successfully unpacked and MD5 sums checked
OE> staged installation is only possible with locking
OE> ** using non-staged installation
OE> ** libs
OE> gcc -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -L/usr/local/lib -Wall px.c -o px
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c init.c -o init.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c api-common.c -o api-common.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c common.c -o common.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c extra.c -o extra.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c dummy.c -o dummy.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c error-codes.c -o error-codes.o
OE> gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include   -fpic  -D__MUSL__  -Wall -pedantic -fdiagnostics-color=always -c posix.c -o posix.o
OE> posix.c:32:10: fatal error: linux/types.h: No such file or directory
OE>    32 | #include <linux/types.h>
OE>       |          ^~~~~~~~~~~~~~~
OE> compilation terminated.
OE> make: *** [/usr/local/lib/R/etc/Makeconf:168: posix.o] Error 1
OE> ERROR: compilation failed for package ‘ps’
OE> * removing ‘/tmp/RtmpekcpoD/pkg-lib3104384ea56/ps’

gaborcsardi avatar Oct 25 '22 11:10 gaborcsardi

This should be fixed in pak now. Please reopen if you encounter this issue again.

gaborcsardi avatar Feb 01 '23 11:02 gaborcsardi