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
Recommendations for caching poetry dependencies causes the wrong python version to be used for poetry install #846
Comments
Hello @sdb9696 |
Hello @sdb9696 – my team ran into this same issue recently. We solved it by pinning the python version in our [tool.poetry.dependencies]
python = "3.11.4" |
Thanks @andwaredev but we run our CI against all supported python versions to check there are no issues so not sure this workaround will help. |
I find it highly concerning that the recommend and only working solution for caching poetry venvs is to install poetry before This is what I would like to see working: - uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'poetry'
- run: pipx install poetry |
It's always struck me as a bad chicken/egg problem that poetry is the only cache type that requires the environment manager to be installed before it can be used. Even pipenv is not required to be installed
The Poetry default cache location is well known and I bet in CI the vase majority of projects are using that case. The big difference appears to be that the Poetry option is trying to support the fact that Poetry can install virtual environments in the project. Pipenv can also do this but it's just ignored for that option. I'd recommend just caching the default location like Pipenv, or you could have an option for enabling caching in project virtual environments it people use it. |
@silverwind You can tell poetry to use a specific version of python prior to running install https://python-poetry.org/docs/managing-environments#switching-between-environments |
@evilhamsterman doesn't really help me if there is simply no |
This also makes the assumtion that you have pipx which I do not :) I'd highly recommend to install poetry as part of this python version fetching if cache is set to poetry. Chances are everyone is going to need poetry if they are using poetry cache, so maybe get the specific python version with poetry pre-installed. This seems to be the only viable solution. |
I think |
Apparently, it doesn't so to install poetry without pip and having a poetry cache, this would be the ideal: - uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'poetry'
- uses: snok/install-poetry@v1 |
Description:
The recommendations for caching poetry dependencies causes the wrong python version to be used for
poetry install
.Because pipx install poetry happens before
setup-python
and By default, Poetry will try to use the Python version used during Poetry’s installation to create the virtual environment for the current project.Maybe the solution here is to update the docs to make sure that users know to run
poetry env use ${{ steps.setup-python.outputs.python-path }}python
prior to runningpoetry install
. I have not tested that works however.Action version:
v5
Platform:
Runner type:
Tools version:
All versions of python affected except the default version installed on the github runner.
Repro steps:
Follow the steps outlined in advance-usage.md for caching poetry dependencies.
Run
poetry install
Expected behavior:
poetry install
should use the version of python set bysetup-python
Actual behavior:
poetry install
uses the default version of python from the runner os.The text was updated successfully, but these errors were encountered: