snok / install-poetry

Github action for installing and configuring Poetry
MIT License
572 stars 53 forks source link

poetry: command not found - When running multiple self-hosted runners on the same machine. #123

Closed MalteEbner closed 1 year ago

MalteEbner commented 1 year ago

We use the snok action to install poetry in a GitHub action:

    - name: Install Poetry
      uses: snok/install-poetry@v1

We randomly get errors like this one:

Setting Poetry installation path as /home/lightly/.local
Installing Poetry πŸ‘·
Retrieving Poetry metadata
The latest version (1.4.2) is already installed.
/home/lightly/actions-runner/runner_01/_work/_actions/snok/install-poetry/v1/main.sh: line 36: poetry: command not found
Error: Process completed with exit code 127.

Then retriggering exactly the same job sometimes lets it run through:

Run snok/install-poetry@v1
Run $GITHUB_ACTION_PATH/main.sh
Setting Poetry installation path as /home/lightly/.local
Installing Poetry πŸ‘·
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
...
Installing Poetry (1.4.2): Done
Poetry (1.4.2) is installed now. Great!
You can test that everything is set up by executing:
`poetry --version`
Installation completed. Configuring settings πŸ› 
Done βœ…

The big difference is that the first (failing) run found an already installed version.

Error cause suspicion

The runs are executed by self-hosted runners on a custom machine with ubuntu 20.04. As the machine has multiple runners, it can happen that multiple runners install and use poetry at the same time. They might even install different versions, as they might run for different branches. This can be the reason for the error, e.g. one runner cleaning up a poetry install that another runner relies on.

Runner-specific poetry installation

How can we install poetry using the snok action in a runner specific directory? Currently, it always uses the home directory, see INSTALL_PATH="$HOME/.local"

Our machine:

lightly@lightly-gpu-01:~$ ls /home/lightly/.local
bin  lib  share  venv  VERSION
lightly@lightly-gpu-01:~$ ls ~/actions-runner
cpu_runner_01  cpu_runner_03  cpu_runner_05  cpu_runner_02  cpu_runner_04  cpu_runner_06
lightly@lightly-gpu-01:~$ 
sondrelg commented 1 year ago

Hmm I see :thinking: I think I would maybe try to just replace the action with - run: pipx install poetry and see if that works for you

JonasKs commented 1 year ago

Could be a caching issue?

MalteEbner commented 1 year ago

We solved it by the moment by ensuring that all our GitHub actions use exactly the same poetry version.

MalteEbner commented 3 months ago

Possible duplicate of https://github.com/snok/install-poetry/issues/141