r-lib / pak

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

pak::pak() doesn't have a way to pass arbitrary environment variables #500

Open ArnaudKunzi opened 1 year ago

ArnaudKunzi commented 1 year ago

Some packages have build-time options passed by environment variables, e.g. package V8:

image

On Archlinux, compiling libv8 is bit bothersome with build deps on python2 etc... so setting DOWNLOAD_STATIC_V8=1 is actually desirable.
However, sys.setEnv(DOWNLOAD_STATIC_V8=1) doesn't seem to work as the env variable isn't passed to the subprocesses. It seems only ENV variables prefixed with PKG_ are, and pak::pak() doesn't propagate parameters not prefixed with pkg. either.

install.packages() works as intended in this instance.

Did I overlook a mechanism to pass the environment variable or is this indeed not possible at the moment?

> sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Arch Linux

System info:

> uname -a Linux main 6.3.4-arch2-1 #1 SMP PREEMPT_DYNAMIC Mon, 29 May 2023 13:58:34 +0000 x86_64 GNU/Linux

gaborcsardi commented 1 year ago

You can set the env vars before starting R or before loading pak and then they will be inherited in the subprocess.