Describe the Bug
Looking forward to understand how this issue can be sorted
root@46eb8e9e6272:/opt/program/source# asdf set poetry 2.1.3
root@46eb8e9e6272:/opt/program/source# asdf set python 3.10.17
root@46eb8e9e6272:/opt/program/source# python --version
Python 3.10.17
root@46eb8e9e6272:/opt/program/source# poetry env use $(asdf which python)
Creating virtualenv ....-py3.10 in /home/AzDevOps/.cache/pypoetry/virtualenvs
Using virtualenv: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-iQ83Tj8g-py3.10
root@46eb8e9e6272:/opt/program/source# poetry env info
Virtualenv
Python: 3.10.12
Implementation: CPython
Path: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-py3.10
Executable: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-py3.10/bin/python
Valid: True
Base
Platform: linux
OS: posix
Python: 3.10.12
Path: /usr
Executable: /usr/bin/python3.10
we decided to take asdf as a package manger and something in the chain of supply failed
the setup
pipelines/ci/0.0/Dockerfile
pipelines/ci/7.0/Dockerfile
0.0 servers as a baseline for all others to consume .tools-versions required for the project
#---Dockerfile 0.0
FROM ubuntu:22.04
ARG IMAGE_VERSION
ARG GIT_REVISION
ARG BUILD_DATE
LABEL org.opencontainers.image.title="standard-ci-0.0" \
...
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.version="${IMAGE_VERSION}" \
org.opencontainers.image.revision="${GIT_REVISION}" \
org.opencontainers.image.created="${BUILD_DATE}"
USER root
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_CTYPE="C.UTF-8"
# bootstrap
COPY scripts/bootstrap/ /tmp/scripts/bootstrap/
COPY resources/bootstrap/ /tmp/resources/bootstrap/
RUN chmod +x /tmp/scripts/bootstrap/*.sh \
&& /tmp/scripts/bootstrap/install_system_packages.sh
ENV AWS_CLI_VERSION=2.11.18
RUN /tmp/scripts/bootstrap/install_aws_cli.sh "${AWS_CLI_VERSION}"
ENV ASDF_VERSION=0.16.7
RUN /tmp/scripts/bootstrap/install_asdf.sh "${ASDF_VERSION}" \
&& rm -rf /tmp/scripts/bootstrap /tmp/resources/bootstrap/
# system
COPY scripts/system/ /tmp/scripts/system/
COPY resources/system/ /tmp/resources/system/
RUN chmod +x /tmp/scripts/system/*.sh
ENV USERNAME= USERNAME
ENV USER_UID=1002
ENV USER_GID=1002
ENV DOCKER_GID=""
RUN /tmp/scripts/system/create_non_root_user.sh \
"${USERNAME}" "${USER_UID}" "${USER_GID}" "${DOCKER_GID}"
# user
COPY scripts/user/ /usr/local/bin/
RUN chmod +x /usr/local/bin/*.sh
USER ${USERNAME}
ENV HOME=/home/${USERNAME}
ENV ASDF_DATA_DIR=${HOME}/.asdf
ENV PATH="${ASDF_DATA_DIR}/bin:${ASDF_DATA_DIR}/shims:/usr/local/bin:${PATH}"
WORKDIR ${HOME}
RUN mkdir -p "${ASDF_DATA_DIR}"
COPY resources/user/ ${HOME}
RUN /usr/local/bin/asdf-init.sh
CMD ["bash"]
#----- asdf-init.sh
#!/usr/bin/env bash
# todo: implement facade
set -euo pipefail
#-------------------------------------------------------------------------------
# This script is used to bootstrap ASDF plugins and versions
# It reads the .tool-versions file, installs the specified plugins and versions,
# and sets the default version for each plugin.
# If .tool-versions exits successfully immediately
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# FUNCTIONS
#-------------------------------------------------------------------------------
function add_asdf_plugin() {
local runtime=$1
if [ -z "$runtime" ]; then
echo " Error: No runtime specified for adding ASDF plugin."
return 1
fi
if asdf plugin list | grep -q "^$runtime$"; then
echo " ASDF plugin for '$runtime' is already installed."
else
echo " Adding ASDF plugin for '$runtime'..."
asdf plugin add "$runtime" || {
echo "Error: Failed to add ASDF plugin for '$runtime'."
return 1
}
echo " ASDF plugin for '$runtime' added successfully."
fi
}
#-------------------------------------------------------------------------------
# MAIN
#-------------------------------------------------------------------------------
TOOL_VERSIONS_FILE=".tool-versions"
TOOL_VERSIONS_BACKUP_FILE=".tool-versions.backup"
TOOL_VERSIONS_TEMP_FILE=".tool-versions.temp"
# exit successfully if no .tool-versions
if [[ ! -f "$TOOL_VERSIONS_FILE" ]]; then
echo "Warning: $TOOL_VERSIONS_FILE not found. Exiting..."
exit 0
fi
# backup original .tool-versions
cp $TOOL_VERSIONS_FILE $TOOL_VERSIONS_BACKUP_FILE
while IFS= read -r line || [[ -n "$line" ]]; do
echo "#---------------------------"
[[ -z "$line" || "$line" =~ ^# ]] && continue
plugin="${line%% *}"
versions="${line#"$plugin"}"
versions="$(echo "$versions" | sed 's/^ *//')"
default_version="$(echo "$versions" | awk '{print $1}')"
echo "🔧 Plugin: $plugin"
echo " Versions: $versions"
echo " Default : $default_version"
# all plugins should be added before installation
add_asdf_plugin $plugin
# write final .tool-versions content
echo "$plugin $default_version" >> "$TOOL_VERSIONS_TEMP_FILE"
echo "#---------------------------"
echo
done < "$TOOL_VERSIONS_FILE"
asdf install
mv "$TOOL_VERSIONS_TEMP_FILE" "$TOOL_VERSIONS_FILE"
##--- Dockerfile 7.0
FROM standard-ci/0.0:stable
ARG IMAGE_VERSION
ARG GIT_REVISION
ARG BUILD_DATE
LABEL org.opencontainers.image.title="standard-ci-7.0" \
...
org.opencontainers.image.version="${IMAGE_VERSION}" \
org.opencontainers.image.revision="${GIT_REVISION}" \
org.opencontainers.image.created="${BUILD_DATE}"
WORKDIR $HOME
COPY .tool-versions $HOME/.tool-versions
RUN asdf-init.sh
USER root
CMD ["bash"]
#--- tool-versions
python 3.10.17 3.8.20 3.9.22 3.11.12 3.12.10
poetry 1.8.2 1.5.1 2.1.3
nodejs 20.19.2 21.7.3
java corretto-11.0.27.6.1 corretto-8.442.06.1 corretto-17.0.15.6.1
maven 3.6.3 3.9.9
Steps to Reproduce
see ^^
Expected Behaviour
after execution command poetry env use $(asdf which python)
expect to virtual env to be set based on passed python executable
Actual Behaviour
below commands is self explanatory
root@46eb8e9e6272:/opt/program/source# asdf set poetry 2.1.3
root@46eb8e9e6272:/opt/program/source# asdf set python 3.10.17
root@46eb8e9e6272:/opt/proram/source# python --version
Python 3.10.17
root@46eb8e9e6272:/opt/program/source# poetry env use $(asdf which python)
Creating virtualenv ...-py3.10 in /home/AzDevOps/.cache/pypoetry/virtualenvs
Using virtualenv: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-py3.10
root@46eb8e9e6272:/opt/program/source# poetry env info
Virtualenv
Python: 3.10.12
Implementation: CPython
Path: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-py3.10
Executable: /home/AzDevOps/.cache/pypoetry/virtualenvs/...-py3.10/bin/python
Valid: True
Base
Platform: linux
OS: posix
Python: 3.10.12
Path: /usr
Executable: /usr/bin/python3.10
Environment
asdf plugins affected (if relevant)
No response
Describe the Bug
Looking forward to understand how this issue can be sorted
we decided to take asdf as a package manger and something in the chain of supply failed
the setup
pipelines/ci/0.0/Dockerfile
pipelines/ci/7.0/Dockerfile
0.0 servers as a baseline for all others to consume .tools-versions required for the project
#---Dockerfile 0.0
#----- asdf-init.sh
##--- Dockerfile 7.0
#--- tool-versions
Steps to Reproduce
see ^^
Expected Behaviour
after execution command
poetry env use $(asdf which python)expect to virtual env to be set based on passed python executable
Actual Behaviour
below commands is self explanatory
Environment
asdf plugins affected (if relevant)
No response