Skip to content

.pex files aren't runnable when invoked off the PATH #298

Description

@chrisnovakovic
plz build //:pex # Assume //:pex is a python_binary that outputs test.pex
mkdir /tmp/pathdir
cp -f plz-out/bin/test.pex /tmp/pathdir
export PATH="/tmp/pathdir:$PATH"
test.pex

This should invoke the default run-time Python interpreter with /tmp/pathdir/test.pex as the first argument (modulo any interpreter options), but instead the first argument is (equivalent to) ./test.pex, which then fails because test.pex isn't in the current working directory. This happens because the preamble always assumes that argv[0] is a path relative to the current working directory if it doesn't contain a / character. It should instead emulate the shell's (or execvp(3)'s) PATH searching behaviour in this case.

Activity

  1. added 2 commits that reference this issue on Apr 9, 2026
    cce7cc4
    120c789
  2. added 3 commits that reference this issue on Apr 10, 2026
    3df78e0
    da61c0d
    f502477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions