Skip to content

pipx 1.3 breaks run <app> if app is also a directory in your cwd #1152

@robinvandernoord

Description

@robinvandernoord

In pipx 1.2.x, you could do pipx run py4web version if there was a directory called py4web in your cwd. Since 1.3 up to the latest patch, this leads to an error:

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/pipx", line 8, in <module>
    sys.exit(cli())
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipx/main.py", line 885, in cli
    return run_pipx_command(parsed_pipx_args)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipx/main.py", line 197, in run_pipx_command
    commands.run(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipx/commands/run.py", line 195, in run
    content = None if spec is not None else maybe_script_content(app, is_path)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/pipx/commands/run.py", line 52, in maybe_script_content
    return app_path.read_text(encoding="utf-8")
  File "/usr/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
IsADirectoryError: [Errno 21] Is a directory: 'py4web'

How to reproduce

Create a directory with the same name as a Python package you would use with pipx. Then try to run pipx run <name>.

Expected behavior

I expected the pipx installed app to run like in 1.2.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions