features icon indicating copy to clipboard operation
features copied to clipboard

azure-cli feature installation silently fails if pipx is broken (i.e. when Python version is changed)

Open stewartadam opened this issue 7 months ago • 3 comments

When the pipx binary is present in the container but broken (which can be reproduced by installing a different Python version), the Azure CLI silently fails to install.

Actual results:

  • Build succeeds, but the az command is not available.

Expected results:

  • Build fails if feature installation fails.

Repro steps:

  1. Use the miniconda:0-3 devcontainer image and apply the ghcr.io/devcontainers/features/azure-cli feature
  2. Create a environment.yml which installs a different Python version than used by the base image, for example:
    name: prompt-flow-env
    channels:
      - defaults
    dependencies:
      - python=3.9
      - pip
      - pip:
          - -r requirements.txt
    
  3. Rebuild the devcontainer
Docker logs
#19 [dev_containers_target_stage 4/7] RUN --mount=type=bind,from=dev_containers_feature_content_source,source=azure-cli_0,target=/tmp/build-features-src/azure-cli_0     cp -ar /tmp/build-features-src/azure-cli_0 /tmp/dev-container-features  && chmod -R 0755 /tmp/dev-container-features/azure-cli_0  && cd /tmp/dev-container-features/azure-cli_0  && chmod +x ./devcontainer-features-install.sh  && ./devcontainer-features-install.sh  && rm -rf /tmp/dev-container-features/azure-cli_0
#19 0.201 ===========================================================================
#19 0.201 Feature       : Azure CLI
#19 0.201 Description   : Installs the Azure CLI along with needed dependencies. Useful for base Dockerfiles that often are missing required install dependencies like gpg.
#19 0.201 Id            : ghcr.io/devcontainers/features/azure-cli
#19 0.201 Version       : 1.2.2
#19 0.201 Documentation : https://github.com/devcontainers/features/tree/main/src/azure-cli
#19 0.201 Options       :
#19 0.201     VERSION="latest"
#19 0.201     EXTENSIONS=""
#19 0.201     INSTALLBICEP="false"
#19 0.201     INSTALLUSINGPYTHON="false"
#19 0.201 ===========================================================================
#19 0.206 Effective REMOTE_USER: vscode
#19 0.206 (*) Installing Azure CLI...
#19 0.209 (*) No pre-built binaries available in apt-cache. Installing via pip3.
#19 0.216 Running apt-get update...
#19 0.359 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
#19 0.359 Get:2 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
#19 0.418 Get:3 https://dl.yarnpkg.com/debian stable/main all Packages [10.9 kB]
#19 0.442 Get:4 https://dl.yarnpkg.com/debian stable/main arm64 Packages [10.9 kB]
#19 0.446 Get:5 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
#19 0.571 Get:6 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
#19 0.606 Get:7 http://deb.debian.org/debian bullseye/main arm64 Packages [7951 kB]
#19 1.245 Get:8 http://deb.debian.org/debian-security bullseye-security/main arm64 Packages [256 kB]
#19 1.282 Get:9 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [15.1 kB]
#19 1.916 Fetched 8470 kB in 2s (5096 kB/s)
#19 1.916 Reading package lists...
#19 2.198 Reading package lists...
#19 2.490 Building dependency tree...
#19 2.558 Reading state information...
#19 2.630 libffi-dev is already the newest version (3.3-6).
#19 2.630 python3-minimal is already the newest version (3.9.2-3).
#19 2.630 python3-minimal set to manually installed.
#19 2.630 The following additional packages will be installed:
#19 2.630   javascript-common libjs-jquery libjs-sphinxdoc libjs-underscore
#19 2.630   libpython3-dev libpython3.9 libpython3.9-dev python-pip-whl python3-dev
#19 2.630   python3-distutils python3-lib2to3 python3-pkg-resources python3-setuptools
#19 2.630   python3-wheel python3.9-dev python3.9-venv
#19 2.631 Suggested packages:
#19 2.631   apache2 | lighttpd | httpd python-setuptools-doc
#19 2.741 The following NEW packages will be installed:
#19 2.741   javascript-common libjs-jquery libjs-sphinxdoc libjs-underscore
#19 2.741   libpython3-dev libpython3.9 libpython3.9-dev python-pip-whl python3-dev
#19 2.741   python3-distutils python3-lib2to3 python3-pip python3-pkg-resources
#19 2.741   python3-setuptools python3-venv python3-wheel python3.9-dev python3.9-venv
#19 2.834 0 upgraded, 18 newly installed, 0 to remove and 1 not upgraded.
#19 2.834 Need to get 9594 kB of archives.
#19 2.834 After this operation, 33.4 MB of additional disk space will be used.
#19 2.834 Get:1 http://deb.debian.org/debian bullseye/main arm64 javascript-common all 11+nmu1 [6260 B]
#19 2.869 Get:2 http://deb.debian.org/debian bullseye/main arm64 libjs-jquery all 3.5.1+dfsg+~3.5.5-7 [315 kB]
#19 2.976 Get:3 http://deb.debian.org/debian bullseye/main arm64 libjs-underscore all 1.9.1~dfsg-3 [100 kB]
#19 2.985 Get:4 http://deb.debian.org/debian bullseye/main arm64 libjs-sphinxdoc all 3.4.3-2 [127 kB]
#19 2.997 Get:5 http://deb.debian.org/debian bullseye/main arm64 libpython3.9 arm64 3.9.2-1 [1556 kB]
#19 3.107 Get:6 http://deb.debian.org/debian bullseye/main arm64 libpython3.9-dev arm64 3.9.2-1 [3835 kB]
#19 3.424 Get:7 http://deb.debian.org/debian bullseye/main arm64 libpython3-dev arm64 3.9.2-3 [21.7 kB]
#19 3.424 Get:8 http://deb.debian.org/debian bullseye/main arm64 python-pip-whl all 20.3.4-4+deb11u1 [1948 kB]
#19 3.533 Get:9 http://deb.debian.org/debian bullseye/main arm64 python3.9-dev arm64 3.9.2-1 [515 kB]
#19 3.576 Get:10 http://deb.debian.org/debian bullseye/main arm64 python3-lib2to3 all 3.9.2-1 [77.8 kB]
#19 3.576 Get:11 http://deb.debian.org/debian bullseye/main arm64 python3-distutils all 3.9.2-1 [143 kB]
#19 3.584 Get:12 http://deb.debian.org/debian bullseye/main arm64 python3-dev arm64 3.9.2-3 [24.8 kB]
#19 3.587 Get:13 http://deb.debian.org/debian bullseye/main arm64 python3-pkg-resources all 52.0.0-4 [190 kB]
#19 3.594 Get:14 http://deb.debian.org/debian bullseye/main arm64 python3-setuptools all 52.0.0-4 [366 kB]
#19 3.624 Get:15 http://deb.debian.org/debian bullseye/main arm64 python3-wheel all 0.34.2-1 [24.0 kB]
#19 3.626 Get:16 http://deb.debian.org/debian bullseye/main arm64 python3-pip all 20.3.4-4+deb11u1 [337 kB]
#19 3.725 Get:17 http://deb.debian.org/debian bullseye/main arm64 python3.9-venv arm64 3.9.2-1 [5396 B]
#19 3.725 Get:18 http://deb.debian.org/debian bullseye/main arm64 python3-venv arm64 3.9.2-3 [1188 B]
#19 4.183 Fetched 9594 kB in 1s (9779 kB/s)
#19 4.198 Selecting previously unselected package javascript-common.
(Reading database ... 26159 files and directories currently installed.)
#19 4.240 Preparing to unpack .../00-javascript-common_11+nmu1_all.deb ...
#19 4.246 Unpacking javascript-common (11+nmu1) ...
#19 4.257 Selecting previously unselected package libjs-jquery.
#19 4.258 Preparing to unpack .../01-libjs-jquery_3.5.1+dfsg+~3.5.5-7_all.deb ...
#19 4.262 Unpacking libjs-jquery (3.5.1+dfsg+~3.5.5-7) ...
#19 4.287 Selecting previously unselected package libjs-underscore.
#19 4.289 Preparing to unpack .../02-libjs-underscore_1.9.1~dfsg-3_all.deb ...
#19 4.290 Unpacking libjs-underscore (1.9.1~dfsg-3) ...
#19 4.304 Selecting previously unselected package libjs-sphinxdoc.
#19 4.306 Preparing to unpack .../03-libjs-sphinxdoc_3.4.3-2_all.deb ...
#19 4.307 Unpacking libjs-sphinxdoc (3.4.3-2) ...
#19 4.324 Selecting previously unselected package libpython3.9:arm64.
#19 4.325 Preparing to unpack .../04-libpython3.9_3.9.2-1_arm64.deb ...
#19 4.327 Unpacking libpython3.9:arm64 (3.9.2-1) ...
#19 4.424 Selecting previously unselected package libpython3.9-dev:arm64.
#19 4.426 Preparing to unpack .../05-libpython3.9-dev_3.9.2-1_arm64.deb ...
#19 4.427 Unpacking libpython3.9-dev:arm64 (3.9.2-1) ...
#19 4.663 Selecting previously unselected package libpython3-dev:arm64.
#19 4.664 Preparing to unpack .../06-libpython3-dev_3.9.2-3_arm64.deb ...
#19 4.665 Unpacking libpython3-dev:arm64 (3.9.2-3) ...
#19 4.675 Selecting previously unselected package python-pip-whl.
#19 4.676 Preparing to unpack .../07-python-pip-whl_20.3.4-4+deb11u1_all.deb ...
#19 4.677 Unpacking python-pip-whl (20.3.4-4+deb11u1) ...
#19 4.768 Selecting previously unselected package python3.9-dev.
#19 4.770 Preparing to unpack .../08-python3.9-dev_3.9.2-1_arm64.deb ...
#19 4.771 Unpacking python3.9-dev (3.9.2-1) ...
#19 4.786 Selecting previously unselected package python3-lib2to3.
#19 4.788 Preparing to unpack .../09-python3-lib2to3_3.9.2-1_all.deb ...
#19 4.789 Unpacking python3-lib2to3 (3.9.2-1) ...
#19 4.803 Selecting previously unselected package python3-distutils.
#19 4.804 Preparing to unpack .../10-python3-distutils_3.9.2-1_all.deb ...
#19 4.805 Unpacking python3-distutils (3.9.2-1) ...
#19 4.821 Selecting previously unselected package python3-dev.
#19 4.823 Preparing to unpack .../11-python3-dev_3.9.2-3_arm64.deb ...
#19 4.824 Unpacking python3-dev (3.9.2-3) ...
#19 4.834 Selecting previously unselected package python3-pkg-resources.
#19 4.836 Preparing to unpack .../12-python3-pkg-resources_52.0.0-4_all.deb ...
#19 4.837 Unpacking python3-pkg-resources (52.0.0-4) ...
#19 4.857 Selecting previously unselected package python3-setuptools.
#19 4.858 Preparing to unpack .../13-python3-setuptools_52.0.0-4_all.deb ...
#19 4.860 Unpacking python3-setuptools (52.0.0-4) ...
#19 4.889 Selecting previously unselected package python3-wheel.
#19 4.891 Preparing to unpack .../14-python3-wheel_0.34.2-1_all.deb ...
#19 4.892 Unpacking python3-wheel (0.34.2-1) ...
#19 4.903 Selecting previously unselected package python3-pip.
#19 4.904 Preparing to unpack .../15-python3-pip_20.3.4-4+deb11u1_all.deb ...
#19 4.905 Unpacking python3-pip (20.3.4-4+deb11u1) ...
#19 4.935 Selecting previously unselected package python3.9-venv.
#19 4.936 Preparing to unpack .../16-python3.9-venv_3.9.2-1_arm64.deb ...
#19 4.937 Unpacking python3.9-venv (3.9.2-1) ...
#19 4.946 Selecting previously unselected package python3-venv.
#19 4.948 Preparing to unpack .../17-python3-venv_3.9.2-3_arm64.deb ...
#19 4.949 Unpacking python3-venv (3.9.2-3) ...
#19 4.962 Setting up python3-pkg-resources (52.0.0-4) ...
#19 5.059 Setting up javascript-common (11+nmu1) ...
#19 5.069 Setting up python3-wheel (0.34.2-1) ...
#19 5.136 Setting up libpython3.9:arm64 (3.9.2-1) ...
#19 5.139 Setting up python-pip-whl (20.3.4-4+deb11u1) ...
#19 5.142 Setting up libjs-jquery (3.5.1+dfsg+~3.5.5-7) ...
#19 5.147 Setting up python3-lib2to3 (3.9.2-1) ...
#19 5.194 Setting up libjs-underscore (1.9.1~dfsg-3) ...
#19 5.196 Setting up python3-distutils (3.9.2-1) ...
#19 5.259 Setting up python3-setuptools (52.0.0-4) ...
#19 5.438 Setting up libpython3.9-dev:arm64 (3.9.2-1) ...
#19 5.440 Setting up python3-pip (20.3.4-4+deb11u1) ...
#19 5.565 Setting up libjs-sphinxdoc (3.4.3-2) ...
#19 5.568 Setting up python3.9-dev (3.9.2-1) ...
#19 5.570 Setting up python3.9-venv (3.9.2-1) ...
#19 5.592 Setting up libpython3-dev:arm64 (3.9.2-3) ...
#19 5.594 Setting up python3-venv (3.9.2-3) ...
#19 5.597 Setting up python3-dev (3.9.2-3) ...
#19 5.599 Processing triggers for man-db (2.9.4-2) ...
#19 5.682 Processing triggers for libc-bin (2.31-13+deb11u7) ...
#19 5.776 Traceback (most recent call last):
#19 5.776   File "/usr/local/py-utils/bin/pipx", line 5, in <module>
#19 5.776     from pipx.main import cli
#19 5.776 ModuleNotFoundError: No module named 'pipx'
#19 5.777 Could not install azure-cli via pip3
#19 5.778 (*) Attempting to install globally with pipx...
#19 5.778 declare -x DEBIAN_FRONTEND="noninteractive"
#19 5.778 declare -x EXTENSIONS=""
#19 5.778 declare -x HOME="/root"
#19 5.778 declare -x INSTALLBICEP="false"
#19 5.778 declare -x INSTALLUSINGPYTHON="false"
#19 5.778 declare -x LANG="C.UTF-8"
#19 5.778 declare -x LC_ALL="C.UTF-8"
#19 5.778 declare -x NVM_DIR="/usr/local/share/nvm"
#19 5.778 declare -x NVM_SYMLINK_CURRENT="true"
#19 5.778 declare -x OLDPWD="/"
#19 5.778 declare -x PATH="/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/share/nvm/current/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
#19 5.778 declare -x PIPX_BIN_DIR="/usr/local/bin"
#19 5.778 declare -x PIPX_HOME="/usr/local/pipx"
#19 5.778 declare -x PIP_CACHE_DIR="/tmp/pip-tmp/cache"
#19 5.778 declare -x PWD="/tmp/dev-container-features/azure-cli_0"
#19 5.778 declare -x PYTHONUSERBASE="/tmp/pip-tmp"
#19 5.778 declare -x PYTHON_PATH="/usr/local/python/current"
#19 5.778 declare -x SHLVL="1"
#19 5.778 declare -x VERSION="11 (bullseye)"
#19 5.778 declare -x _CONTAINER_USER="root"
#19 5.778 declare -x _CONTAINER_USER_HOME="/root"
#19 5.778 declare -x _REMOTE_USER="vscode"
#19 5.778 declare -x _REMOTE_USER_HOME="/home/vscode"
#19 5.778 declare -- ver=""
#19 5.786 Traceback (most recent call last):
#19 5.786   File "/usr/local/py-utils/bin/pipx", line 5, in <module>
#19 5.786     from pipx.main import cli
#19 5.786 ModuleNotFoundError: No module named 'pipx'
#19 5.788 (*) Finished installing globally with pipx.
#19 5.788 Installing Azure CLI extensions: 
#19 5.792 Done!
#19 DONE 5.8s

This is easier to trigger on Apple Silicon, I suspect because there's no pre-packaged azure-cli in the repo so it falls back to the pipx installation procedure.

Note that explicitly requesting the ghcr.io/devcontainers/features/python:1 feature in the end-user's devcontainer.json (in hopes it re-runs the pipx installation sequence that was originally run during te miniconda image setup) has no effect as the install.sh checks for the presence of the pipx command, which does exist (it just doesn't execute).

stewartadam avatar Dec 21 '23 05:12 stewartadam