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

Aperta
#1,720 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:python-functions bug python
Lingua principale
Python
Stelle
357
Fork
116
Merge medio
32m
PR unite (30g)
1

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia individuando le definizioni di build delle immagini di base Azure Functions Python v3 e v4 e riproduci i quattro casi di Dockerfile descritti nell’issue, incluso il workaround di ldconfig. Confronta come viene generata la cache delle librerie condivise; il lavoro è completato quando le immagini Python supportate consentono al programma di installazione di Poetry di trovare libpython3.9.so.1.0 e libpython3.10.so.1.0 senza un workaround manuale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, docker, python
Ambito
cloud, infrastructure
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.