Skip to content
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

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

Closed
robinvandernoord opened this issue Dec 15, 2023 · 2 comments · Fixed by #1155
Closed

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

robinvandernoord opened this issue Dec 15, 2023 · 2 comments · Fixed by #1155
Labels
bug Something isn't working

Comments

@robinvandernoord
Copy link

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

@dukecat0 dukecat0 added the bug Something isn't working label Dec 15, 2023
@dukecat0
Copy link
Member

Probably we should only treat the app name as local script when it contains:

  • .py extension
  • A shebang line at the beginning of script

...Or providing a new option called --ignore-local/-i? (Since we have --path which forces pipx to find the script locally.)

@robinvandernoord
Copy link
Author

I would prefer the first solution since it's more backwards compatible, if there was an option for it I have to change a lot of docker build scripts and other tooling that use pipx.

maxwell-k added a commit to maxwell-k/dotfiles that referenced this issue Dec 29, 2023
@Gitznik Gitznik mentioned this issue Jan 11, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants