setup-python: Unhelpful error message related to unresolvable python version
Description:
When neither python-version
or python-version-file
is set, and there is no version file matching python-version-file
’s default (.python-version
), the error message could use an improvement. Currently it is not helpful, and even somewhat confusing.
Action version: v4.0.0
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version:
All.
Repro steps:
https://github.com/scop/bash-completion/runs/6798283007?check_suite_focus=true#step:3:1
Expected behavior: Helpful error message. For example:
Error: Could not determine Python version to set up. Please either specify a version using
python-version
in the action configuration, or path to a valid version file usingpython-version-file
. The version file currently in effect, /home/runner/work/bash-completion/bash-completion/.python-version, does not exist.
Actual behavior: Unhelpful error message:
Error: The specified python version file at: /home/runner/work/bash-completion/bash-completion/.python-version does not exist
There are two problems with this:
- I did not specify a python version file
- It’s kind of an unexpected change coming from setup-python v3, and does not point towards a good way to fix it. The only hint is towards pointing to
.python-version
which isn’t arguably good advice, because those files in many workflows are not something that are supposed to be checked in to git in the first place, because they are expected to contain for example pyenv virtual env names which are specific to developer local setups, not something to share. In that sense, it is also a quite unfortunate default.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 22 (5 by maintainers)
Commits related to this issue
- Update to latest GitHub Action versions checkout@v2 -> v3 upload/download-artifact@v2 -> v3 python-setup@v2 -> v3 pypa/gh-action-pypi-publish@1.4.2 -> v1.5.0 Python latest is v4, but it brea... — committed to abitrolly/cibuildwheel by abitrolly 2 years ago
- According to https://github.com/actions/setup-python/issues/421\#issuecomment-1174810835 we need to specify the python version — committed to vraravam/ferdium-app by vraravam 3 months ago
Is there any reason why it can’t just default to the previous behavior when no
python-version
is provided and the.python-version
file does not exist?I see myself touching a lot of repositories to get this merged otherwise since i tend to just use the latest version provided by the action when i’m using it in the context of having to run some generic python tooling rather than working on an actual python project.
Would the recommended solution be to just use the system python that is provided by the runner?
Regardless of whether the semantics get brought back to v3, having a clearer error message about needing to specify one of
python-version
orpython-version-file
would help.The official way to specify Python version is using
pyproject.toml
.Thank you for your suggestions, @scop and @abitrolly ❤️ They really make sense, so we will try to make documentation and change logs clearer.
IMO, it would have been better to update
setup-ruby
to matchsetup-node
andsetup-python
, rather than remove something useful (especially for beginners) fromsetup-python
. Alsosetup-ruby
was moved toruby/setup-ruby
, so it’s not even inactions/
anymore.Also, it should be pointed out that
.ruby-version
is forrbenv
, which is a very standard and common way to configure multiple Ruby’s - I use it on all my Ruby projects. While.python-version
is frompyenv
, which is a fork of rbenv for Python and much less of a standard; it is not properly supported by many tools like CMake, nox, tox, etc. I’ve personally only used it to compile beta versions once in a while, and I work on dozens of Python projects. I believe far more people use Conda in Python, which gets the Python version very differently. And there are other active experiments in multiple Python support. Supporting it is fine, but forcing it is not ideal.I realized that setting
python-version: "3.x"
or">=3.7"
does at least remove the need to update the Python version once a year - if a default is not going to be re-added, then I can start updating my projects, examples, cookiecutter, and tutorials to use that.Perhaps somewhat cosmetic as far as the real world effects go, but note that per the usage docs, this supports “SemVer’s version range syntax”, which I guess means https://docs.npmjs.com/cli/v6/using-npm/semver#ranges. In that sense, one might want to use something like
>=3.6
if there’s a lower bound and the intent is that not all 3.x versions are fine. And it would, for better or for worse, probably also mean that major versions > 3 (if they ever materialize) would match.I’ve got lots of repositories with things like:
(and tutorials, etc). All of them will have to have a manual version added, that now needs to be updated yearly. It does seem like a default to fall back on “latest” if the version file isn’t present like v1-v3 would be really nice if possible! These repo’s don’t have a single Python “version” that should be locked by a file, it’s just needed to do a bit of Python for style, updates, etc. The regular CI jobs have the normal matrix of versions. Adding the
.python-version
is great, but losing the ability to run this in a single line and getting the latest Python seems like a downgrade. (Maybe there’s some technical reason I couldn’t find?) (Also, there doesn’t seem to be a way to specify latest at all - #300).I dont see a clear reason in the changelog. I agree with the proposed behaviour. This quite big breaking change is unnecessary/avoidable.
The latest stable python was always the default, the user has the ability to choose if they want a specific version. Plus a reason to not go forward with this, is the fact that dependabot doesn’t update to the latest version of python defined in the workflow, only the action, meaning pinning vulnerable tags is going to be more common.