Skip to content

tools installed with pipx don't work: no $HOME/.local/bin in PATH #128

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

Open
satwell opened this issue Jun 30, 2024 · 1 comment · May be fixed by #130
Open

tools installed with pipx don't work: no $HOME/.local/bin in PATH #128

satwell opened this issue Jun 30, 2024 · 1 comment · May be fixed by #130

Comments

@satwell
Copy link

satwell commented Jun 30, 2024

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.

@satwell
Copy link
Author

satwell commented Jun 30, 2024

It's easy to add /root/.local/bin to PATH in /etc/environment. But it's not clear to me whether non-root users need to be supported?

Since act runner execs bash with --noprofile --norc, the only option I can see for expanding $HOME while setting PATH is to use BASH_ENV. Basically, create a file somewhere that contains export PATH="$HOME/.local/bin:$PATH" and set BASH_ENV to the location of that file. Then bash will source that script when run non-interactively by act runner.

Which is the better option here? The simple root-only solution, or the more complex but work-for-all-users solution? Happy to contribute a PR for either.

@satwell satwell linked a pull request Jul 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant