question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry caching fails because Poetry is not installed

See original GitHub issue

Description: Poetry caching fails because Poetry is not installed.

Action version: v3

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version: All Python versions.

Repro steps:
Run a workflow with the setup-python action using the cache: 'poetry' argument. I have set up a minimal reproduction in a public repository. There is an example of a failed workflow run in that project.

Expected behavior: I would expect Poetry dependencies to be restored if they exist.

Actual behavior: The step fails due to a missing poetry executable.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
jirojo2commented, Sep 12, 2022

Doesn’t work for me as of today @4.2.0

8reactions
tonycommented, Apr 2, 2022

The reason I’m not filing a separate is I think it’d be closed on the same grounds as this issue.

But I’d like to note my workaround for python versions and poetry 1.x to work:

It looks like installing poetry before actions/setup-python causes poetry to use the earlier python version. e.g. if GH uses python 3.8 by default and poetry is installed in that, your poetry is going to run in 3.8, no matter what actions/setup-python is.

It looks like poetry install doesn’t obey the python version that actions/setup-python uses.

Here’s an example

My workaround is to use a matrix and poetry env <version>

name: tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [ '3.10' ]
    steps:
      - uses: actions/checkout@v3
      - name: Install poetry
        run: |
          curl -O -sSL https://install.python-poetry.org/install-poetry.py
          python install-poetry.py -y --version 1.1.12
          echo "PATH=${HOME}/.poetry/bin:${PATH}" >> $GITHUB_ENV
          rm install-poetry.py

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'poetry'

      - name: Install dependencies
        run: |
          # This is required to do as of @actions/checkout@v3 to prevent default action python (3.8) from being used
          poetry env use ${{ matrix.python-version }}
          poetry install

      - name: Lint with flake8
        run: poetry run flake8

      - name: Print python versions
        run: |
          python -V
          poetry run python -V

      - name: Test with pytest
        run: poetry run py.test

You can replace "Install poetrywithpipx install poetry, or pipx install poetry==1.1.12`, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Commands | master | Documentation | Poetry - Python ...
--no-cache : Disables Poetry source caches. --directory=DIRECTORY (-C) : The working directory for the Poetry command (defaults to the current working ...
Read more >
Poetry fails whenever I try to run cicd in GitHub Actions
I'm facing a problem with Poetry and GitHub actions in the last days. Maybe because Poetry has an updated version. Information.
Read more >
Poetry vs. Docker caching: Fight! - Python⇒Speed
Poetry's versioning scheme for Python dependencies makes Docker caching harder, which means slower images rebuilds. Learn some workarounds.
Read more >
Poetry Advance - Python Biella Group
This problem can occur as soon as you run a library installation or do poetry install or poetry update . ⚠ Attention ⚠...
Read more >
How To Install Poetry to Manage Python Dependencies on ...
txt . In this tutorial you will install Poetry using the official installation script, set up a Poetry project with a virtual environment,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found