Rblpapi icon indicating copy to clipboard operation
Rblpapi copied to clipboard

installation fails on Alpine Linux

Open bastistician opened this issue 1 month ago • 6 comments

The pre-compiled Bloomberg binaries that the package downloads during installation seem to assume a glibc-based Linux OS. On Alpine Linux, I get:

** using staged installation
Setting up compilation for a linux x86_64 system
** libs
[...]
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'Rblpapi' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/runner/R-patched/lib/00LOCK-Rblpapi/00new/Rblpapi/libs/Rblpapi.so':
  Error loading shared library libresolv.so.2: No such file or directory (needed by /home/runner/R-patched/lib/00LOCK-Rblpapi/00new/Rblpapi/libs/../blp/libblpapi3_64.so)
Error: loading failed

ldd additionally shows:

Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by blp/libblpapi3_64.so)
Error relocating blp/libblpapi3_64.so: __register_atfork: symbol not found
Error relocating blp/libblpapi3_64.so: __strdup: symbol not found
Error relocating blp/libblpapi3_64.so: setcontext: symbol not found
Error relocating blp/libblpapi3_64.so: __strftime_l: symbol not found
Error relocating blp/libblpapi3_64.so: makecontext: symbol not found
Error relocating blp/libblpapi3_64.so: backtrace: symbol not found
Error relocating blp/libblpapi3_64.so: getcontext: symbol not found

AFAICS, the only thing this R package could do about this is to clarify the restriction in the SystemRequirements, https://github.com/Rblp/Rblpapi/blob/ec8da696f78935dfa6864e81407c1afa0913e436/DESCRIPTION#L19-L21 and maybe also in the README#Status Section, so this becomes a known limitation. (I'll put 'Rblpapi' on my "stoplist".)

bastistician avatar Oct 28 '25 18:10 bastistician

Yes there may be little else we can do here other than support a stop list. For example, we also no longer get macOS amd64 from Bloomberg.

Note though that I control at run-time from R via a function haveBlp() which follows a compile-time #define for HaveBlp. We could possibly set that to false on Alpine / with Musl. You would get a package that builds, but is an empty shell (and tells you so).

The logic is in configure (a shell script) and currently very simple (as we all tend to ignore marginal platforms beyond (real, uncrippled) Linux and macOS). We want to get into the else part starting on line 37 which relies on (constant, pre-made) src/Makevars.

eddelbuettel avatar Oct 28 '25 18:10 eddelbuettel

So I guess we could do something like this quick awk statement:

$ docker run --rm -ti alpine:3.22 awk -F= '/^ID=/ {print $2}' /etc/os-release
alpine
$  awk -F= '/^ID=/ {print $2}' /etc/os-release
ubuntu
$

And I guess utils::osVersion has something similar if we have R (which I don't in the alpine container).

eddelbuettel avatar Oct 29 '25 20:10 eddelbuettel

Oh nice. Even better if musl-based systems could be handled in the configure setup.

Maybe grepping in R.version$os (set from autoconf's ${host_os}) would be good enough to detect macOS ("darwin") and Alpine ("musl") builds, respectively.

R> R.version$os
[1] "linux-musl"
R> osVersion
[1] "Alpine Linux v3.22"

bastistician avatar Oct 29 '25 22:10 bastistician

So maybe this might suit as alpine will fail it while other linux-gnu systems will pass?

modified   configure
@@ -30,7 +30,8 @@ fi
 ## At CRAN or R-universe we encounter nothing else.
 : ${R_HOME=$(R RHOME)}
 sysname=$(${R_HOME}/bin/Rscript -e 'cat(Sys.info()["sysname"])')
-if [ ${sysname} = "Linux" ]; then
+osname=$(${R_HOME}/bin/Rscript -e 'cat(R.version$os)')
+if [ ${sysname} = "Linux" ] & [ ${osname} = "linux-gnu" ]; then
     platform="linux"
 elif [ ${sysname} = "Darwin" ]; then
     platform="osx"

eddelbuettel avatar Oct 29 '25 22:10 eddelbuettel

Or specifically exclude musl hosts, so "${osname}" != "linux-musl".

bastistician avatar Oct 29 '25 22:10 bastistician

Yes, narrower is better. I also show the "${osname}" now:

modified   configure                                                                                                                                                                                               
@@ -30,12 +30,13 @@ fi                                                                                                                                                                                             
 ## At CRAN or R-universe we encounter nothing else.                                                                                                                                                               
 : ${R_HOME=$(R RHOME)}                                                                                                                                                                                            
 sysname=$(${R_HOME}/bin/Rscript -e 'cat(Sys.info()["sysname"])')                                                                                                                                                  
-if [ ${sysname} = "Linux" ]; then                                                                                                                                                                                 
+osname=$(${R_HOME}/bin/Rscript -e 'cat(R.version$os)')                                                                                                                                                            
+if [ ${sysname} = "Linux" ] & [ ${osname} != "linux-musl" ]; then                                                                                                                                                 
     platform="linux"                                                                                                                                                                                              
 elif [ ${sysname} = "Darwin" ]; then                                                                                                                                                                              
     platform="osx"                                                                                                                                                                                                
 else                                                                                                                                                                                                              
-    echo "Unsupported platform: $sysname"                                                                                                                                                                         
+    echo "Unsupported platform: ${sysname} (${osname})"                                                                                                                                                           
     echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first."                                                                                                          
     echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi."                                                                                                                    
     echo "The build will proceed but not be functional for lack of a library."                                                                                                                                    

eddelbuettel avatar Oct 29 '25 22:10 eddelbuettel