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

Regression: click.launch() broken on Windows in version 8.1.8 #2868

Open
ivankravets opened this issue Mar 10, 2025 · 4 comments
Open

Regression: click.launch() broken on Windows in version 8.1.8 #2868

ivankravets opened this issue Mar 10, 2025 · 4 comments
Labels

Comments

@ivankravets
Copy link

click.launch("https://click.palletsprojects.com/en/stable/") results in [WinError 2] The system cannot find the file specified on Windows due to an incorrect migration from os.system to subprocess.call. Refer to the official documentation:

Replacing `os.system()`

sts = os.system("mycmd" + " myarg")
# becomes
retcode = call("mycmd" + " myarg", shell=True)

Proposed fix ivankravets@fb59f90

Environment:

  • Python version: 3.x
  • Click version: 8.1.8
@davidism
Copy link
Member

We do not want to use shell=True, so you'll need to find a different fix.

@ivankravets
Copy link
Author

Sorry, but I’m not sure I understand you. The API has been working since the first version of Click (more than 10 years), and the documentation highlights the use of click.launch() in multiple places for opening web URLs. See: https://click.palletsprojects.com/en/stable/utils/#launching-applications

Could you revert that part of the code if there is no solution that avoids breaking an API that has worked for multiple years? The launch function is a high-level abstraction and should not expose the end developer to OS-related technical issues.

@davidism
Copy link
Member

I'm not saying this isn't a bug, I'm saying we don't want to use shell=True. So the fix is not to revert it or use shell=True, but to research and fix it another way.

@johannkm
Copy link

johannkm commented Apr 1, 2025

I also ran in to this. Here's where this was introduced: #1477

I believe it would work to use the same error handling for windows as this diff adds for Linux: https://github.com/pallets/click/blob/stable/src/click/_termui_impl.py#L673-L679, with a fallback to webbrowser.open()

@Rowlando13 Rowlando13 added the bug label Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants