question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent python on mac depending on bash option

See original GitHub issue

Describe 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 or master)

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
moblecommented, Jan 19, 2021

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 run export PATH="$pythonLocation:$PATH" inside your list of commands in each bash -l section.

1reaction
jspaakscommented, Sep 7, 2020

Thanks @moble, this report helped me solve my error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent python3 and pip3 on OSX - Stack Overflow
I cannot figure out how to get the correct version of pip3 on my Mac as the default. I installed and ...
Read more >
Inconsistent invocation of Python versions with pythontex - TeX
I'm using latexmk like this: latexmk -pdf --shell-escape file_with_console_content.tex and I cannot see how to use that suggested workaround, at ...
Read more >
Inconsistent results using cut on output of ls - Super User
As I want to run the command in a bash script I am trying to get ... are dependent on whether or not...
Read more >
(Python) inconsistent use of tabs and spaces in indentation
press CTRL + Shift + P or ( ⌘ + Shift + P on Mac) to open the command palette. type: "convert indentation...
Read more >
Python: inconsistent use of tabs and spaces in indentation
Indentation is important in Python because the language doesn't depend on syntax like curly brackets to denote where a block of code starts...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found