Azure / Azure/azure-functions-python-worker

[Bug] `ld.so.cache` is out of date, leading to `libpython3.10.so.1.0: cannot open shared object file` error

Offen
#1,720 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:python-functions bug python
Vorherrschende Sprache
Python
Sterne
357
Forks
116
Ø Merge
32 Min.
Gemergte PRs (30 T.)
1

Beschreibung

### Expected Behavior

I expected that while installing the [poetry package manager](https://python-poetry.org/), the poetry install process would find all Python shared libraries.

### Actual Behavior

Instead the error `1.119 /home/.local/share/pypoetry/venv/bin/python3: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory` is shown.

This install process worked in the function runtime v3 images, and seems to be caused by `ld.so.cache` being out of date. A work-around for the issue is running `ldconfig`.

### Steps to Reproduce

I'm going to provide four example Dockerfiles.

The first Dockerfile demonstrates that one can install Poetry in this manner using a v3 runtime, and Python 3.9.

The second Dockerfile demonstrates that this does not work in a v4 runtime, again using Python 3.9.

The third Dockerfile demonstrates a work-around: if you run `ldconfig` before installing poetry, it works again.

The fourth Dockerfile demonstrates that bug can occur in v4 using Python 3.10, in order to demonstrate the bug with a supported version of the runtime and a supported version of Python.

### Relevant code being tried

```shell
# This works in v3
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9
RUN curl -sSL https://install.python-poetry.org | python3 -; \
saved=$?; \
cat /poetry-*.log; \
exit $saved
```

```shell
# This fails in v4, only changing runtime version
FROM mcr.microsoft.com/azure-functions/python:4-python3.9
RUN curl -sSL https://install.python-poetry.org | python3 -; \
saved=$?; \
cat /poetry-*.log; \
exit $saved
```

```shell
# This works in v4, using ldconfig workaround
FROM mcr.microsoft.com/azure-functions/python:4-python3.9
RUN ldconfig
RUN curl -sSL https://install.python-poetry.org | python3 -; \
saved=$?; \
cat /poetry-*.log; \
exit $saved
```

```shell
# This fails, while using a supported version of Python
FROM mcr.microsoft.com/azure-functions/python:4-python3.10
RUN curl -sSL https://install.python-poetry.org | python3 -; \
saved=$?; \
cat /poetry-*.log; \
exit $saved
```

### Relevant log output

This corresponds to the Dockerfile labelled `# This works in v3`

```shell

Sending build context to Docker daemon 13MB
Step 1/2 : FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9
---> 414c8b656d7d
Step 2/2 : RUN curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved
---> Running in 4e66901f724c
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (2.1.3)
Installing Poetry (2.1.3): Creating environment
Installing Poetry (2.1.3): Installing Poetry
Installing Poetry (2.1.3): Creating script
Installing Poetry (2.1.3): Done

Poetry (2.1.3) is installed now. Great!

To get started you need Poetry's bin directory (/home/.local/bin) in your `PATH`
environment variable.

Add `export PATH="/home/.local/bin:$PATH"` to your shell configuration file.

Alternatively, you can call Poetry explicitly with `/home/.local/bin/poetry`.

You can test that everything is set up by executing:

`poetry --version`

cat: '/poetry-*.log': No such file or directory
---> Removed intermediate container 4e66901f724c
---> 6f890f3bf05e
Successfully built 6f890f3bf05e
Successfully tagged reprex:latest
```

This corresponds to the Dockerfile labelled `# This fails in v4, only changing runtime version`

```
Sending build context to Docker daemon 13MB
Step 1/2 : FROM mcr.microsoft.com/azure-functions/python:4-python3.9
---> aa17fc245253
Step 2/2 : RUN curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved
---> Running in 25b6c75f7fe7
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (2.1.3)
Installing Poetry (2.1.3): Creating environment
Installing Poetry (2.1.3): An error occurred. Removing partial environment.
Poetry installation failed.
See /poetry-installer-error-twmuhwt6.log for error logs.
/home/.local/share/pypoetry/venv/bin/python3: error while loading shared libraries: libpython3.9.so.1.0: cannot open shared object file: No such file or directory

Traceback:

File "", line 937, in main
File "", line 576, in run
The command '/bin/sh -c curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved' returned a non-zero code: 127
```

This corresponds to the Dockerfile labelled `# This works in v4, using ldconfig workaround`.

```
Sending build context to Docker daemon 13MB
Step 1/3 : FROM mcr.microsoft.com/azure-functions/python:4-python3.9
---> aa17fc245253
Step 2/3 : RUN ldconfig
---> Running in 4e4897eba9b8
---> Removed intermediate container 4e4897eba9b8
---> 7f252faa3c92
Step 3/3 : RUN curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved
---> Running in c8e50746fb94
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (2.1.3)
Installing Poetry (2.1.3): Creating environment
Installing Poetry (2.1.3): Installing Poetry
Installing Poetry (2.1.3): Creating script
Installing Poetry (2.1.3): Done

Poetry (2.1.3) is installed now. Great!

To get started you need Poetry's bin directory (/home/.local/bin) in your `PATH`
environment variable.

Add `export PATH="/home/.local/bin:$PATH"` to your shell configuration file.

Alternatively, you can call Poetry explicitly with `/home/.local/bin/poetry`.

You can test that everything is set up by executing:

`poetry --version`

cat: '/poetry-*.log': No such file or directory
---> Removed intermediate container c8e50746fb94
---> 3e21ffb4af08
Successfully built 3e21ffb4af08
Successfully tagged reprex:latest
```

This corresponds to the Dockerfile labelled `# This fails, while using a supported version of Python`

```
Sending build context to Docker daemon 13MB
Step 1/2 : FROM mcr.microsoft.com/azure-functions/python:4-python3.10
---> 32712b6e2a5f
Step 2/2 : RUN curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved
---> Running in dea2f8530ac0
Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/home/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (2.1.3)
Installing Poetry (2.1.3): Creating environment
Installing Poetry (2.1.3): An error occurred. Removing partial environment.
Poetry installation failed.
See /poetry-installer-error-9hlz8jrz.log for error logs.
/home/.local/share/pypoetry/venv/bin/python3: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

Traceback:

File "", line 937, in main
File "", line 576, in run
The command '/bin/sh -c curl -sSL https://install.python-poetry.org | python3 -; saved=$?; cat /poetry-*.log; exit $saved' returned a non-zero code: 127
```

### requirements.txt file

```shell
N/A - issue occurs prior to installing packages
```

### Where are you facing this problem?

Local - Core Tools

### Function app name

_No response_

### Additional Information

I suggest that `ldconfig` be run in the base image so that others who want to install Poetry can do so without encountering this error.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die Build-Definitionen der Azure Functions Python v3- und v4-Basis-Images zu finden, und reproduziere die vier im Issue beschriebenen Dockerfile-Fälle einschließlich des ldconfig-Workarounds. Vergleiche, wie der Cache für gemeinsam genutzte Bibliotheken erzeugt wird; fertig ist die Arbeit, wenn die unterstützten Python-Images es dem Poetry-Installer ermöglichen, libpython3.9.so.1.0 und libpython3.10.so.1.0 ohne manuellen Workaround zu finden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, docker, python
Bereich
cloud, infrastructure
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.