Skip to content
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

Catch pyenv-python mismatches #47

Closed
d-ryan-ashcraft opened this issue Sep 6, 2023 · 2 comments
Closed

Catch pyenv-python mismatches #47

d-ryan-ashcraft opened this issue Sep 6, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@d-ryan-ashcraft
Copy link
Contributor

d-ryan-ashcraft commented Sep 6, 2023

Defect

If you are using pyenv to manage your python versions but don't have the path configured correctly, a false-positive situation can arrive where pyenv reports the correct target version, but the underlying python version does not match.

For instance, consider the following scenario:

  • pyenv is configured to use 3.11.4 but not correctly configured on your path
  • python version on the path is 3.11.0

When you build, habushu will delegate to pyenv and it will report version 3.11.4 is being using. But in fact, it will be using 3.11.0. It's hard to detect because the virtual environment only uses 3.11 in the name. We noticed only when python was set to an older minor version (3.9), making the virtual environment mismatch more apparent.

Given how difficult this is to detect, it would be nice if Habushu checked for the situation and errored out with a useful error message to help the user correct the situation.

Test Steps

  • Update path to include a python version you aren't using in pyenv
    • For example: export PATH=/<pathToPyenv>/.pyenv/versions/<version>/bin:/<pathToPyenv>/.pyenv/bin:<the rest of your path - BUT NOT the valid pyenv shims path!>
  • Run habushu
  • Receive an appropriate error message
@d-ryan-ashcraft
Copy link
Contributor Author

Test results:

[INFO] --- habushu:2.8.0-SNAPSHOT:validate-pyenv-and-poetry (default-validate-pyenv-and-poetry) @ habushu-mixology ---
[INFO] Using Python 3.11.4 (managed by pyenv)
[INFO] Found Poetry 1.6.1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for habushu::Root 2.8.0-SNAPSHOT:
[INFO] 
[INFO] habushu::Root ...................................... SUCCESS [  0.455 s]
[INFO] habushu::Mixing Drinks with Habushu ................ FAILURE [  0.720 s]
[INFO] habushu::Mixing Drinks with Habushu Consumer ....... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.161 s
[INFO] Finished at: 2023-09-07T10:53:03-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.technologybrewery.habushu:habushu-maven-plugin:2.8.0-SNAPSHOT:validate-pyenv-and-poetry (default-validate-pyenv-and-poetry) on project habushu-mixology: 
[ERROR] [Expected 'pyenv' to set Python to 3.11.4 but instead found 3.9.16!, 'pyenv' is installed, but not configured correctly.  Ensure your PATH includes 'pyenv init -' expected content!]

@d-ryan-ashcraft d-ryan-ashcraft self-assigned this Sep 7, 2023
@d-ryan-ashcraft d-ryan-ashcraft added the bug Something isn't working label Sep 7, 2023
@d-ryan-ashcraft d-ryan-ashcraft added this to the 2.7.1 milestone Sep 7, 2023
d-ryan-ashcraft added a commit that referenced this issue Sep 7, 2023
…on-check

#47 🥅 catch pyenv vs. system python configuration mismatch
@d-ryan-ashcraft
Copy link
Contributor Author

CI build passed:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant