-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry caching fails because Poetry is not installed #369
Comments
Hello @nwjsmith. Thank you for your report. It's an expected behaviour because the setup-python action uses poetry to get its configuration. Poetry should be preinstalled before using the setup-python action. For now I'm going to close the issue. |
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 It looks like Here's an example
My workaround is to use a matrix and 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 poetry |
Hello @tony. Thank you for your report. I'll reopen the issue for deeper investigation. |
@dmitry-shibanov I created an independent issue here: #374 (with a minimal recreation example: https://github.com/tony/setup-python-poetry-version-example/) |
See actions/setup-python#369 This reverts commit 6f4366d.
Hello everyone. For now I'm going to close the issue because we released a new version with fix and updated major tag. |
Doesn't work for me as of today @4.2.0 |
This isn't fixed...the error still occurs as of today |
Same issue here. Using version 4.5.0 |
@dmitry-shibanov this issue is not fixed...any chance we can re-open this issue? |
Sorry for a meaningless +1, but just bumped into this issue too. Hoping to see this fixed! |
This should be reopened. The docs also still indicate that poetry must be installed before using this action: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages I think it goes without saying, but until this gets resolved, python being a prerequisite of poetry renders the use of this action pretty much pointless |
In all runners images there is already a relatively recent version of python 3 pre-installed (Included Software column), which can be used without problems to install poetry (except for Ubuntu 18.04 which will be discontinued), and python installed by setup-python after poetry is recognized normally when the virtual env is created, which doesn't cause any problems. I think that if it is not done in this sequence, setup-python would need to install poetry too, and why should it install poetry and not other options like pipenv, hatch, pdm...? Does it make sense for setup-python to have options to install these tools as well, or should it just focus on python? And if you really need to install poetry on a specific version of python, you can use setup-python without use the cache options, install poetry, and call actions/cache directly afterward. |
I don't know about other people's use cases, but consider this scenario:
In this scenario, using the cache option will fail because poetry doesn't exist, but why does poetry need to exist before the cache is even accessed? It hasn't installed any packages yet |
@EvanShaw because this action run |
I would like to advocate for the dependency on poetry to be removed. I'm trying to get this working on my company's own test runners but it's a pain, pip isn't preinstalled so I can't simply install poetry like in the examples. EDIT: Turns out in my case this was a pretty easy fix, I just had to |
The action should therefore install |
Oops, I forgot about pre-installed software on each runner, and they all have python and pipx. My mistake... |
Need poetry install before, but it would not use the correct Python version See actions/setup-python#369
this is still an issue. Reopen? it is very counter intuitive to assume |
It seems the issue you are encountering is related to the absence of the Poetry executable during the caching step. When using the setup-python action with the cache: 'poetry' argument, the workflow expects Poetry to be pre-installed to restore dependencies. To address this, ensure that Poetry is explicitly installed as part of your workflow setup before attempting to cache dependencies. You can add a step to install Poetry using pip install poetry or leverage a dedicated action for Poetry setup. Meanwhile, if you're in the mood for some reflective moments, take a break and explore Sad Shayari in Hindi, a soothing collection for those emotional breaks between debugging sessions. Example Fix: yaml For a more heartfelt collection of poetic content, explore Emotional Sad Shayari – it might provide some comfort during those tough debugging moments. |
Description:
Poetry caching fails because Poetry is not installed.
Action version:
v3
Platform:
Runner type:
Tools version:
All Python versions.
Repro steps:
Run a workflow with the
setup-python
action using thecache: '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.The text was updated successfully, but these errors were encountered: