Inconsistent python on mac depending on bash option
See original GitHub issueDescribe the bug
There’s a really unfortunate and mostly silent bug that happens only on macos
— not on ubuntu
or windows
. I’m not sure whether this issue could be solved more easily by setup-python
or by virtual-environments
, but this is where I think people will look to find this issue. If nothing else, I feel like it should be documented here.
Somewhere, I have a fairly complicated run
section that (so that Windows doesn’t go nuts) needs bash features — but also the login option to bash. Out of inertia, this became my way of running things:
runs-on: macos-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Some fancy thing
shell: bash -l {0}
run: |
# Some bashy fanciness
python --version
But the python that gets picked up on macos only is the wrong one — i.e., not 3.8. The reason is obvious if you’re looking for it: using bash -l
prepends /usr/local/bin:/usr/bin
to PATH
. The problem is that users probably aren’t looking for it; their scripts are silently using the wrong version of python. Again, this is not the behavior on ubuntu or windows, both of which have their PATH
variables ordered correctly to find the desired version of python. It’s that difference in behavior that I’m calling a bug, and I think it’s clear that ubuntu and windows have the preferable behavior.
Which version of the action are you using?
-
v1
-
v2
- Some other tag (such as
v2.0.1
ormaster
)
Environment
- self-hosted
- Linux
- Windows
- Mac
If applicable, please specify if you’re using a container
Python Versions All versions on Mac
To Reproduce
Run a python command with bash -l
as the shell on any mac instance with any python version. A simple workflow is here
Run/Repo Url
https://github.com/moble/test_github_actions_python/actions/runs/222351275
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (3 by maintainers)
Top GitHub Comments
Just for anyone who skipped to the bottom of this thread: again, @torressa’s problem is unrelated. The workaround for the problem mentioned at the beginning of this issue is to use bash without
-l
if possible, or to runexport PATH="$pythonLocation:$PATH"
inside your list of commands in eachbash -l
section.Thanks @moble, this report helped me solve my error.