Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation failure in Alpine Linux Apptainer (Singularity) build #1486

Closed
glm729 opened this issue Sep 20, 2022 · 10 comments
Closed

Installation failure in Alpine Linux Apptainer (Singularity) build #1486

glm729 opened this issue Sep 20, 2022 · 10 comments

Comments

@glm729
Copy link

glm729 commented Sep 20, 2022

When attempting to install the rlang package in an Apptainer image build (in the %post section), the package compiles but then appears to fail loading from the temporary location.

To make it a bit more convoluted, the Alpine Linux build is being run inside a Windows 10 WSL2 image of Ubuntu 20.04.

The Apptainer image is an extension of an existing custom image, extending the alpine:3.16 Docker image, for using a portable R setup inside various systems, including HPC. The final / output image from that R config does not show any other problems.

A Docker build running the same installation command does not fail.

Creating a package installation directory other than /usr/lib/R/library or /usr/lib/R/site-library, e.g. /tmp/test-libs, and installing the packages there does not result in a failure, but this is not optimal -- preferably, package installations should occur in the system-wide library for any user to make use of when using this image.

Please let me know if there is any more information I should provide!


Package installation call

Also fails with dependencies = FALSE.

Rscript -e 'install.packages("rlang", dependencies = TRUE)'

iconvlist() output

This was run from the final image of the previous step, i.e. equivalently just before calling install.packages.

Apptainer> Rscript -e 'print(iconvlist());'
 [1] "..."       "ISO8859-1" "ISO8859-2" "ISO8859-3" "ISO8859-4" "ISO8859-5"
 [7] "ISO8859-6" "ISO8859-7" "UCS-2BE"   "UCS-2LE"   "US_ASCII"  "UTF-16BE"
[13] "UTF-16LE"  "UTF-32BE"  "UTF-8"     "UTF32-LE"  "WCHAR_T"

Apptainer def fragment

This is the Apptainer def file used. The def file for the Alpine_R image is much larger, and can be provided if of interest.

Bootstrap: localimage
From: <home>/Apptainer_Sandbox/alpine_r/

%post
  Rscript -e 'install.packages("rlang", dependencies = FALSE)'

Console output

This is the console output for attempting to install the package itself, with dependencies = FALSE, by running apptainer build --fakeroot --sandbox with the def file shown above.

Console output
* installing *source* package 'rlang' ...
** package 'rlang' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/usr/include/R" -DNDEBUG -I./rlang/  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -D__USE_MISC -c capture.c -o capture.o
gcc -I"/usr/include/R" -DNDEBUG -I./rlang/  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -D__USE_MISC -c internal.c -o internal.o
g++ -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I./rlang/  -I/usr/local/include  -D__MUSL__ -fpic  -g -O2  -D__MUSL__ -c rlang-rcc.cpp -o rlang-rcc.o
gcc -I"/usr/include/R" -DNDEBUG -I./rlang/  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -D__USE_MISC -c rlang.c -o rlang.o
gcc -I"/usr/include/R" -DNDEBUG -I./rlang/  -I/usr/local/include  -fvisibility=hidden -fpic  -g -O2  -D__USE_MISC -c version.c -o version.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -L/usr/local/lib -o rlang.so capture.o internal.o rlang-rcc.o rlang.o version.o -L/usr/lib/R/lib -lR
installing to /usr/lib/R/library/00LOCK-rlang/00new/rlang/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
Error: package or namespace load failed for 'rlang':
 .onLoad failed in loadNamespace() for 'rlang', details:
  call: utils::packageVersion(pkg)
  error: there is no package called 'rlang'
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/usr/lib/R/library/rlang'
@glm729
Copy link
Author

glm729 commented Sep 20, 2022

Out of interest, I attempted to install pak to try to install the development version. This fails when the rlang dependency install is attempted, but this is what happens for pak itself:

Console output
* installing *source* package 'pak' ...
** package 'pak' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
**** building pak dependency data, this can take several minutes
**** deps data (23): .Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.10.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.20Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT'
23
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (pak)
make: Target 'all' not remade because of errors.

So, it looks like there is possibly some system library that is required but not installed, or is otherwise not readable for some reason? Odd that this doesn't happen for a Docker build or when entering the shell and running the installation there.

@lionel-
Copy link
Member

lionel- commented Sep 20, 2022

Doing a google search on the error message:

.Error in FUN(X[[i]], ...) :
  unsupported conversion from 'UTF-8' to 'ASCII//TRANSLIT

suggests it's an iconv issue. Someone mentions here (api-platform/api-platform#1532) that it's an Alpine bug, and suggests this fix: nunomaduro/phpinsights#43 (comment).

I don't think this is an rlang issue.

cc @gaborcsardi in case he has already seen this

@gaborcsardi
Copy link
Member

gaborcsardi commented Sep 20, 2022

This is a side issue, but the easiest way to install pak is from the pre-built binaries, assuming you are on x86_64 or arm64: https://github.com/r-lib/pak#pre-built-binaries

@glm729
Copy link
Author

glm729 commented Sep 20, 2022

Thank you for the very quick replies! I might have been too specific when I tried to search for the error, I did not find the same results.

My problem in this case is not that I need to install pak, but rlang itself, as it is a dependency for the bigsnpr package, used within some current refactoring / extension work of a previous PhD student's code. I'll try the workaround suggested for iconv when I'm back at my work computer tomorrow morning.

One additional note is that I did one more test installing rlang in the Apptainer image shell before I left work today, and it works if I create a directory that is not related to the host filesystem. Then, I might be able to move the directory under /usr/lib/R/library. But if iconv can be fixed (or worked around) otherwise, then I will settle with that first.

@gaborcsardi
Copy link
Member

I attempted to install pak to try to install the development version. This fails when the rlang dependency install is attempted, but this is what happens for pak itself:

Just to be clear, pak does not depend on rlang.

It also seems to me that the installation of other packages as fails, based on your output when installing pak from source. So maybe this issue is not specific to rlang?

@glm729
Copy link
Author

glm729 commented Sep 20, 2022

pak does not depend on rlang

Interesting! Is dependencies = TRUE perhaps a bit overactive, also pulling in packages listed as "Suggests"? rlang was pulled in and installed when I attempted to install pak with dependencies = TRUE. To be certain of this though, I will check the last command -- it is entirely possible that I tried to install both at once and have completely forgotten, it was the last thing I tried before I left work.

Actually, I am inclined to think I tried to install both pak and rlang -- the packages that are failing are those that depend on rlang. So, I think that, for the pak-related problems, I have tried to install more than just pak in the same command, and I forgot that I did so in that case. But I will check and test that tomorrow to be sure.

Overall, I think this is not specific to rlang -- I first noticed it when installing rlang, but the problem appears to lie with iconv in Alpine Linux in Apptainer (but not Docker, for some reason). Please do close the ticket if it is not applicable.

Also, I'm a bit of a fan of your work, so apologies if I'm nerding out a bit :)

@glm729
Copy link
Author

glm729 commented Sep 20, 2022

Follow-up to my comment from yesterday about installing pak -- rlang is pulled in when running install.packages("pak", dependencies = TRUE):

> install.packages("pak", dependencies=TRUE, Ncpus=parallel::detectCores())
also installing the dependencies 'sys', 'utf8', 'askpass', 'pillar', 'pkgconfig',
'vctrs', 'lazyeval', 'mime', 'openssl', 'fs', 'diffobj', 'fansi', 'rematch2', 'tibble',
'R6', 'rex', 'httr', 'crayon', 'yaml', 'rappdirs', 'lpSolve', 'pkgbuild', 'zip',
'parsedate', 'brio', 'ellipsis', 'evaluate', 'lifecycle', 'magrittr', 'pkgload',
'praise', 'rlang', 'waldo', 'callr', 'cli', 'covr', 'curl', 'desc', 'digest', 'distro',
'filelock', 'gitcreds', 'glue', 'mockery', 'pingr', 'jsonlite', 'pkgcache',
'pkgdepends', 'pkgsearch', 'prettyunits', 'processx', 'ps', 'rprojroot', 'rstudioapi',
'testthat', 'withr'

...

It appears, based on package metadata provided by my local mirror (this file), that eight of these depend on rlang: ellipsis, lifecycle, pillar, pkgload, testthat, tibble, vctrs, and waldo. So, it looks like the packages listed as "Suggests" are also pulled in, which I see is an effect from using dependencies = TRUE rather than providing a vector of specific headers. I didn't pick that up before now!

@glm729
Copy link
Author

glm729 commented Sep 20, 2022

Fixed! Adding the package gnu-libiconv by adding apk add gnu-libiconv to the Apptainer def file appears to solve the installation failure. A more complete test may be needed to be sure, but this looks like it should work in a full rebuild.

@glm729
Copy link
Author

glm729 commented Sep 21, 2022

Another update! Installing the gnu-iconv package did not work, but compiling GNU iconv from source did work. So, this is now fixed (rlang installing fine during a build, no errors), but this is an Alpine Linux problem and not an rlang problem.

Thank you again for your help!

@lionel-
Copy link
Member

lionel- commented Sep 21, 2022

Cool, glad you solved your issue!

@lionel- lionel- closed this as completed Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants