GeezerVison is showing github.com — v3.1's default poetry example uses wrong python version · Issue #374 · actions/setup-python
v3.1's default poetry example uses wrong python version #374Labels bugSomething isn't working DescriptionDescription:
The default configuration example for #281's new example installs poetry before actions/setup-python is ran.
This can run into some funky issues in poetry itself since poetry may stick to use the python version it was installed in.
This may be on the poetry side. I'm not sure:
Action version:
v3.1
Platform:
Runner type:
Tools version:
Repro steps:
Reproduction repo: https://github.com/tony/setup-python-poetry-version-example
Runs: https://github.com/tony/setup-python-poetry-version-example/actions
Expected behavior:
poetry should respect the version in actions/setup-python
Actual behavior:
It uses the python version poetry was installed with before actions/setup-python was ran. Reacted by Olli Paakkunainen, Junpei Kawamoto, Ben Falk, Lenon, Sam Thomson, Mikael Briolet, Robert Shecter, Thorben Dahl, Takahiro Ueda, Carlos Pereira Atencio and 5 more Reacted by Mikko Ohtamaa Activitychanged the title [-]actions/setup-python v3.1's default poetry configuration example uses wrong python version[/-] [+]v3.1's default poetry example uses wrong python version[/+] on Apr 3, 2022matthew-mcallister commented on Apr 4, 2022 How hard would it be to defer caching to a later step? Then you wouldn't have to rely on the system version of Python. I'm thinking something like this:
- name: Install Python
uses: actions/setup-python@v3
with: # Install Python, skip caching
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: python -m pip install poetry
- name: Cache Poetry deps
uses: actions/setup-python@v3
with: # Restore cache, skip Python installation
cache: poetryReacted by Junpei Kawamoto dhvcc commented on Apr 5, 2022 falkben commented on Apr 5, 2022 You can get around this problem by telling poetry to use the same version of python as installed by setup-python with the poetry env use command
This has been working for me:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.10"
cache: "poetry"
- name: Install dependencies
run: |
poetry env use "3.10"
poetry install --no-interactionReacted by Lenon, Sam Thomson, Marco Aguiar, Mikael Briolet, Kazuya Takei, Mahmoud Hanafy, rinat715, Miyar, Stephen Fuqua, Sylvain Lesage and 14 more dogweather commented on Apr 10, 2022 Really weird: I do not get this error on a feature branch / PR:

But I do get the wrong Python version after merged to master:

dogweather commented on Apr 10, 2022 @falkben Your recipe works for me if I disable caching. Otherwise, it still uses the wrong Python. I introduced caching in the latest PR. I'm thinking I might need to delete the cache for some reason. dogweather commented on Apr 10, 2022 Well, I can't find a way to delete the cache, so I've disabled it for now, and the correct Python is used again on master. dhvcc commented on Apr 10, 2022 @dogweather, for me it seems like poetry's ignoring your poetry env use because it thinks that your're already using this env (since config/env values are retrieved from cache). While this behaviour is ok, the strange part is why does it execute the wrong version in the end shelper commented on Jun 10, 2022 dmitry-shibanov commented on Aug 10, 2022 Hello everyone. Sorry for the late response. We released a new version of the action and updated the major tag with possible fix. Could you please confirm that everything works as expected. Reacted by Alexey and Robson Piere Reacted by Mikko Ohtamaa Tenzer commented on Aug 11, 2022 I can confirm the latest version (4.2.0) fixes the problem in the places I've previously had to add the poetry env use 3.10 workaround. Thanks! Reacted by vs and Shelper dmitry-shibanov commented on Aug 15, 2022 Hello @Tenzer. Thank you for your response. For now I'm going to close the issue. omBratteng commented on Aug 31, 2022 I encountered this issue as well, and spent some time trying to figure out why this was still happening after upgrading the action to v4.2.0.
It is cache, it had the wrong python version cached.
To solve it, I used the GitHub API to get a list of caches, and then delete it. Once done, I re-ran the workflow, and it rebuilt the cache and had the correct python version. Reacted by Robert Shecter, call and Abraham Briñez dogweather commented on Aug 31, 2022
To solve it, I used the GitHub API to get a list of caches, and then delete it.
How did you delete it? Where did you delete it from? omBratteng commented on Aug 31, 2022
To solve it, I used the GitHub API to get a list of caches, and then delete it.
How did you delete it? Where did you delete it from?
First I ran this, to get a list of the caches, in this case, there was only one.
gh api \
-H "Accept: application/vnd.github+json" \
/repos/OWNER/REPO/actions/caches
Then I ran this, to delete the cache, based off of the cache ID in the previous command.
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
/repos/OWNER/REPO/actions/caches/CACHE_ID
More information available here: https://docs.github.com/en/rest/actions/cache Reacted by Robert Shecter, call and Abraham Briñez Reacted by Robert Shecter and call
MetadataMetadatabugSomething isn't working DevelopmentNo branches or pull requestsIssue actions
|