devcontainers-contrib / features

🐳 Extra add-in features for Devcontainers and GitHub Codespaces
MIT License
214 stars 111 forks source link

[Bug]: elixir-asdf feature installation fails on Debian base images due to installing Ubuntu specific apt packages #520

Closed cgrothaus closed 6 months ago

cgrothaus commented 10 months ago

Feature id and version

ghcr.io/devcontainers-contrib/features/elixir-asdf:2

Devcontainer base Image

mcr.microsoft.com/devcontainers/base:debian

What happened?

Summary

Installation of elixir-asdf feature fails on a Debian base image.

Reason: it wants to install Ubuntu specific apt packages.

Details

This is the relevant line from the log output: The command 'apt-get install -y --no-install-recommends build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk procps' failed. error: Return Code: 100.

When I execute that apt command manually in a shell inside a fresh dev container, I get this output:

$ sudo apt install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk procps
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libwxgtk3.0-gtk3-dev
E: Couldn't find any package by glob 'libwxgtk3.0-gtk3-dev'
E: Unable to locate package libwxgtk-webview3.0-gtk3-dev
E: Couldn't find any package by glob 'libwxgtk-webview3.0-gtk3-dev'
E: Unable to locate package openjdk-11-jdk

So, the offending packages are

I searched around a bit:

$ apt-cache search "libwxgt*"
libwxgtk-gl3.2-1 - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 gl library runtime)
libwxgtk-media3.2-1 - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 media library runtime)
libwxgtk-media3.2-dev - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 media library development)
libwxgtk-webview3.2-1 - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 webview library runtime)
libwxgtk-webview3.2-dev - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 webview library development)
libwxgtk3.2-1 - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 runtime)
libwxgtk3.2-dev - wxWidgets Cross-platform C++ GUI toolkit (GTK 3 development)

$ apt-cache search "openjdk*" 
libasmtools-java - OpenJDK AsmTools
libjax-maven-plugin - Using the xjc goal with OpenJDK 11+
jtreg - Regression Test Harness for the OpenJDK platform
jtreg6 - Regression Test Harness for the OpenJDK platform
openjdk-17-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-17-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-17-doc - OpenJDK Development Kit (JDK) documentation
openjdk-17-jdk - OpenJDK Development Kit (JDK)
openjdk-17-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-17-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-17-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-17-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-17-source - OpenJDK Development Kit (JDK) source files
uwsgi-plugin-jvm-openjdk-17 - Java plugin for uWSGI (OpenJDK 17)
uwsgi-plugin-jwsgi-openjdk-17 - JWSGI plugin for uWSGI (OpenJDK 17)
uwsgi-plugin-ring-openjdk-17 - Closure/Ring plugin for uWSGI (OpenJDK 17)
uwsgi-plugin-servlet-openjdk-17 - JWSGI plugin for uWSGI (OpenJDK 17)

From that output, I guess the relevant package names on Debian 12 are

Further steps

I don't know how to proceed best from here. I see at least two options.

1. Make the apt package names distro (and version) specific

This means to check whether we are on Ubuntu or on Debian. It also needs to take the version into account, as the package names are again different on Debian 11, for example.

Also, the current install.sh does not take Alpine base images into account, but that's another story.

2. Omit wxWidgets and Java

This means to forgo installing these packages automatically. After all, they are marginal aspects IMHO.

It could be stated in the feature README that if you want to compile Erlang with wX or Java bindings, you have to add those packages to your Dockerfile.

Relevant log output

> [vscode dev_containers_target_stage  7/21] RUN chmod -R 0755 /tmp/dev-container-features/elixir-asdf_1 && cd /tmp/dev-container-features/elixir-asdf_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh:
0.165 ===========================================================================
[2023-09-06T15:18:16.728Z] 
0.165 Feature       : Elixir (via asdf)
0.165 Description   : Elixir is a functional, concurrent, general-purpose programming language that runs on the BEAM virtual machine which is also used to implement the Erlang programming language.
0.165 Id            : ghcr.io/devcontainers-contrib/features/elixir-asdf
0.165 Version       : 2.0.18
0.165 Documentation : http://github.com/devcontainers-contrib/features/tree/main/src/elixir-asdf
0.165 Options       :
0.165     ELIXIRVERSION="1.15.4-otp-26"
0.165     ERLANGVERSION="26.0.2"
0.165 ===========================================================================
0.169 bash: cannot set terminal process group (1): Inappropriate ioctl for device
0.169 bash: no job control in this shell
[2023-09-06T15:18:16.728Z] 3.468 nanolayer
6.598 cd /tmp/tmp587sxglt && chmod +x -R . && _REMOTE_USER="vscode" _REMOTE_USER_HOME="/home/vscode" PACKAGES="build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.0-gtk3-dev,libwxgtk-webview3.0-gtk3-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-11-jdk,procps" PPAS="" CLEAN_PPAS="true" PRESERVE_APT_LIST="true" FORCE_PPAS_ON_NON_UBUNTU="false" NANOLAYER_VERBOSE="" NANOLAYER_FORCE_CLI_INSTALLATION="" NANOLAYER_PROPAGATE_CLI_LOCATION="1" NANOLAYER_CLI_LOCATION="/tmp/nanolayer-pvZItqTnOM/nanolayer" bash  -i  +H ./install.sh
6.598 Found a pre-existing nanolayer which were given in env varialbe: /tmp/nanolayer-pvZItqTnOM/nanolayer

6.774 skipping usage of pre-existing nanolayer. (required version v0.4.27 does not match existing version v0.4.45)

9.849 nanolayer

10.37 cp -p -R /var/lib/apt/lists /tmp/tmpfqc0aluj

10.39 apt-get update -y

10.42 
0% [Working]

Get:1 http://d
[2023-09-06T15:18:16.728Z] eb.debian.org/debian bookworm InRelease [151 kB]

10.47 
0% [1 InRelease 4,096 B/151 kB 3%]

0% [Working]

Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]

10.53 
0% [2 InRelease 17.0 kB/52.1 kB 33%]

0% [Waiting for headers]

Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]

10.55 
0% [3 InRelease 18.5 kB/48.0 kB 39%]

0% [Working]
0% [Working]

Get:4 http://deb.debian.org/debian bookworm/main arm64 Packages [8,803 kB]

10.60 
0% [4 Packages 944 B/8,803 kB 0%]
0% [4 Packages 406 kB/8,803 kB 5%]
21% [4 Packages 642 kB/8,803 kB 7%]
71% [4 Packages 6,285 kB/8,803 kB 71%]

93% [Working]
93% [4 Packages store 0 B] [Waiting for headers]

Get:5 http://deb.debian.org/debian bookworm-updates/main arm64 Packages [4,960
[2023-09-06T15:18:16.728Z]  B]

11.64 
93% [4 Packages store 0 B] [5 Packages 4,960 B/4,960 B 100%]

93% [4 Packages store 0 B] [Waiting for headers]

Get:6 http://deb.debian.org/debian-security bookworm-security/main arm64 Packages [58.1 kB]

11.65 
93% [4 Packages store 0 B] [6 Packages 3,776 B/58.1 kB 6%]

93% [4 Packages store 0 B]
93% [4 Packages store 0 B]

96% [Working]
96% [5 Packages store 0 B]

98% [Working]
98% [6 Packages store 0 B]

100% [Working]

Fetched 9,118 kB in 2s (4,707 kB/s)

12.36 
Reading package lists... 0%

Reading package lists... 0%

Reading package lists... 0%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading pa
[2023-09-06T15:18:16.728Z] ckage lists... Done

12.71 apt-get install -y --no-install-recommends build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk procps

12.72 
Reading package lists... 0%

Reading package lists... 0%

Reading package lists... 0%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... 98%

Reading package lists... Done

13.03 
Building dependency tree... 0%

Building dependency tree... 0%

Building dependency tree... 50%

Building dependency tree... 50%

Building dependency tree... Done

13.12 
Reading state information... 0% 

Reading state information... 0%

Reading state information... Done

13.24 E: Unable to locate package libwxgtk3.0-gtk3-dev

13.24 E: Couldn't find any package by glob 'libwxgtk3.0-gtk3
[2023-09-06T15:18:16.728Z] -dev'

13.24 E: Couldn't find any package by regex 'libwxgtk3.0-gtk3-dev'

13.24 E: Unable to locate package libwxgtk-webview3.0-gtk3-dev

13.24 E: Couldn't find any package by glob 'libwxgtk-webview3.0-gtk3-dev'

13.24 E: Couldn't find any package by regex 'libwxgtk-webview3.0-gtk3-dev'

13.24 E: Unable to locate package openjdk-11-jdk

13.26 apt-get clean

13.27 rm -r /var/lib/apt/lists && mv /tmp/tmpfqc0aluj/lists /var/lib/apt/lists
[2023-09-06T15:18:16.728Z] 
13.32 Traceback (most recent call last):

13.32   File "<string>", line 1, in <module>

13.32   File "nanolayer.__main__", line 50, in main

13.32   File "typer.main", line 328, in __call__

13.32   File "typer.main", line 311, in __call__

13.32   File "click.core", line 1130, in __call__

13.32   File "typer.core", line 778, in main

13.32   File "typer.core", line 216, in _main

13.32   File "click.core", line 1657, in invoke

13.32   File "click.core", line 1657, in invoke
[2023-09-06T15:18:16.728Z] 13.32   File "click.core", line 1404, in invoke

13.32   File "click.core", line 760, in invoke

13.32   File "typer.main", line 683, in wrapper

13.32   File "nanolayer.cli.install", line 86, in install_apt_get_packages

13.32   File "nanolayer.installers.apt_get.apt_get_installer", line 108, in install

13.32   File "nanolayer.utils.invoker", line 56, in invoke

13.32 nanolayer.utils.invoker.Invoker.InvokerException: The command 'apt-get install -y --no-install-recommends build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk procps' failed. error: Return Code: 100. see logs for details.

13.45 Traceback (most recent call last):
13.45   File "<string>", line 1, in <module>
13.45   File "nanolayer.__main__", line 50, in main
13.45   File "typer.main", line 328, in __call__
13.45   File "typer.main", line 311, in __call__
13.45   File "
[2023-09-06T15:18:16.728Z] click.core", line 1130, in __call__
13.45   File "typer.core", line 778, in main
13.45   File "typer.core", line 216, in _main
13.45   File "click.core", line 1657, in invoke
13.46   File "click.core", line 1657, in invoke
13.46   File "click.core", line 1404, in invoke
13.46   File "click.core", line 760, in invoke
13.46   File "typer.main", line 683, in wrapper
13.46   File "nanolayer.cli.install", line 65, in install_devcontainer_feature
13.46   File "nanolayer.installers.devcontainer_feature.oci_feature_installer", line 134, in install
13.46   File "nanolayer.utils.invoker", line 56, in invoke
13.46 nanolayer.utils.invoker.Invoker.InvokerException: The command 'cd /tmp/tmp587sxglt && chmod +x -R . && _REMOTE_USER="vscode" _REMOTE_USER_HOME="/home/vscode" PACKAGES="build-essential,autoconf,m4,libncurses5-dev,libwxgtk3.0-gtk3-dev,libwxgtk-webview3.0-gtk3-dev,libgl1-mesa-dev,libglu1-mesa-dev,libpng-dev,libssh-dev,unixodbc-dev,xsltproc,fop,libxml2-utils,libncurses-dev,openjdk-11-jdk,procps" PPAS=""
[2023-09-06T15:18:16.728Z]  CLEAN_PPAS="true" PRESERVE_APT_LIST="true" FORCE_PPAS_ON_NON_UBUNTU="false" NANOLAYER_VERBOSE="" NANOLAYER_FORCE_CLI_INSTALLATION="" NANOLAYER_PROPAGATE_CLI_LOCATION="1" NANOLAYER_CLI_LOCATION="/tmp/nanolayer-pvZItqTnOM/nanolayer" bash  -i  +H ./install.sh' failed. error: Return Code: 1. see logs for details.
13.56 ERROR: Feature "Elixir (via asdf)" (ghcr.io/devcontainers-contrib/features/elixir-asdf) failed to install! Look at the documentation at http://github.com/devcontainers-contrib/features/tree/main/src/elixir-asdf for help troubleshooting this error.
cgrothaus commented 9 months ago

Hi @danielbraun89, any idea on how to proceed with this issue? What do you think of the two options?

danielbraun89 commented 9 months ago

@cgrothaus Apologies for my late response, I had a lot on my plate this month Also thank you for putting the options in a clear way. Between those two I think the choice is easy and would be definitely Option #2 (remove WX and openjdk entirely ) simply because selecting the specific packages for each distribution is just not scalable. However such an action will probably force a major version update for the feature (as people who used to rely on the feature for java installation will have a broken environment). Also the recommendation to add openJDK and WX installation in the dockerfile, while necessary and correct from design point of view, will be counter-intuitive to the devcontainer feature dogma (after all , if the user already tweaks his Dockerfile he may as well install elixir and be done with it.)

The important point however, like you said, is the feature as it is currently implemented is inherently flawed. It fits only apt-get supporting distros (the use of apt-get at all is a major constraint, but even the bash sheband on install.sh as you mentioned, will break in alpine), so it seems like a whole refactor of this feature and many others is unavoidable.

As a short term middle ground I propose a use of apt-get wildcards as workaround that will keep the feature behaving in the same way in the short term. While I aware these will also break in the future no doubt, at least it buys more time for a deeper rethink about multi-distro support.

I have currently tested the following : libwxgtk3.*-dev , libwxgtk-webview3.*-dev and openjdk-1*-jdk with the following: debian-11 , debian-12 , ubuntu-22.04 and ubuntu-20.04 and I seem to get a buildable environment in each

I have added these images as separate feature tests as well

please try ghcr.io/devcontainers-contrib/features/elixir-asdf:2.0.19

cgrothaus commented 9 months ago

Thank you so much for taking the time to dig into this. Your intermediate solution of using apt-get wildcards sounds ok to me. Version 2.0.19 works for me 👍 .