docker_images
docker_images copied to clipboard
tools installed with pipx don't work: no $HOME/.local/bin in PATH
When I try to install Python tools with pipx
, those tools won't run because they get installed into $HOME/.local/bin
, which isn't in PATH
. This fails in act runner, but works fine in GitHub Actions.
Example workflow:
on: push
jobs:
env:
runs-on: ubuntu-latest
steps:
- run: pipx install hatch
- run: hatch --version
Running this under act runner, pipx complains:
| ⚠️ Note: '/root/.local/bin' is not on
| your PATH environment variable.
| These apps will not be globally
| accessible until your PATH is
| updated. Run `pipx ensurepath` to
| automatically add it, or manually
| modify your PATH in your shell's
| config file (i.e. ~/.bashrc).
GitHub's image puts $HOME/.local/bin
into $PATH
. Here's the full path I get by running env
on GitHub:
PATH=/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Note that they also have custom pipx configuration that makes it put installed executables into /opt/pipx_bin
, but this isn't strictly needed, at least for basic functionality.
I can add a step that runs echo "$HOME/.local/bin" >> "$GITHUB_PATH"
as a workaround, as explained in the GitHub Action Docs. This works, but it's an extra step that's not usually required on GitHub to use pipx
. Since $HOME/.local/bin
is an XDG recommendation and is used by more than just pipx
, I suspect adding this will fix some other incompatibilities with GitHub Actions as well.