Skip to content

v3.1's default poetry example uses wrong python version #374

Description

@tony

Description:

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:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

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.

Activity

  1. changed 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, 2022
  2. matthew-mcallister commented on Apr 4, 2022

    @matthew-mcallister

    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: poetry
  3. dhvcc commented on Apr 5, 2022

    @dhvcc
    Contributor

    @matthew-mcallister @tony this action relies on poetry to tell it's config values. The problem with locking poetry onto 1 version can be solved by installing poetry with curl. This action wil help you https://github.com/snok/install-poetry. However, take note, that it's significantly slower than pipx install poetry

  4. falkben commented on Apr 5, 2022

    @falkben

    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-interaction
  5. added a commit that references this issue on Apr 9, 2022
  6. dogweather commented on Apr 10, 2022

    @dogweather

    Really weird: I do not get this error on a feature branch / PR:

    Screen Shot 2022-04-10 at 1 25 53 PM

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

    Screen Shot 2022-04-10 at 1 25 28 PM

  7. dogweather commented on Apr 10, 2022

    @dogweather

    @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.

  8. dogweather commented on Apr 10, 2022

    @dogweather

    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.

  9. dhvcc commented on Apr 10, 2022

    @dhvcc
    Contributor

    @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

  10. added a commit that references this issue on May 28, 2022
  11. shelper commented on Jun 10, 2022

    @shelper

    same for windows, see #425
    and the workaround here does not work 'cus poetry env use 3.x does not work, see python-poetry/poetry#2117

  12. 7 remaining items

  13. dmitry-shibanov commented on Aug 10, 2022

    @dmitry-shibanov
    Contributor

    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.

  14. Tenzer commented on Aug 11, 2022

    @Tenzer

    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!

  15. dmitry-shibanov commented on Aug 15, 2022

    @dmitry-shibanov
    Contributor

    Hello @Tenzer. Thank you for your response. For now I'm going to close the issue.

  16. added a commit that references this issue on Aug 16, 2022
  17. omBratteng commented on Aug 31, 2022

    @omBratteng

    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.

  18. dogweather commented on Aug 31, 2022

    @dogweather

    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?

  19. omBratteng commented on Aug 31, 2022

    @omBratteng

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions