From |kry|ov @end|ng |rom d|@root@org  Wed Jan 10 20:43:31 2024
From: |kry|ov @end|ng |rom d|@root@org (Ivan Krylov)
Date: Wed, 10 Jan 2024 22:43:31 +0300
Subject: [Rd] Sys.which() caching path to `which`
Message-ID: <20240110224331.24ee0edf@Tarkus>

Hello R-devel,

Currently on Unix-like systems, Sys.which incorporates the absolute
path to the `which` executable, obtained at the configure stage:

>    ## hopefully configure found [/usr]/bin/which
>    which <- "@WHICH@"
>    if (!nzchar(which)) {
>        warning("'which' was not found on this platform")

This poses a problem for the Spack package manager and software
distribution. In Spack, like in Nix, Guix, and GoboLinux, packages live
under their own path prefixes, which look like the following:

>> /opt/spack/opt/spack/linux-ubuntu18.04-x86_64_v3/gcc-7.5.0/r-4.3.0-eqteloqhjzix6ta373ruzt5imvvbcesc

Unfortunately, Spack packages are expected to get relocated, changing
the path prefix and invalidating stored paths, including the path to
`which`: <https://github.com/spack/spack/issues/41953>.

Harmen Stoppels, who is not subscribed to R-devel but interested in
making R work in Spack, currently creates a symlink to `which`
<https://github.com/r-devel/r-svn/pull/151> as part of a patch to R.

What would be the minimally disruptive way to avoid this dependency or
at least make it easier to fix post-factum, during relocation? What
would be the pitfall if Sys.which() were to find `which` on the $PATH
by itself, without remembering the full path?

-- 
Best regards,
Ivan



[Rd] Sys.which() caching path to `which`
Ivan Krylov