-
Notifications
You must be signed in to change notification settings - Fork 4
Crash when running a script via an association #90
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
Comments
Looking at the code indicated in the log, it appears that the new launcher isn't capable of handling a script without a shebang line 🙁 |
It's meant to raise and then handle the error. It's just the path where it tries to auto-install the runtime you need (because you don't currently have any) isn't handling that case - the section of |
OK, so what I need is for it to use my installed Python 3.13. Is it only willing to use managed installs? Is this another consequence of the fact that it can't handle the situation where the latest (i.e. default) available version isn't a managed install? If so, then I could sort of accept that this is a consequence of trying to use this while 3.14 is still in beta. Although (1) that's going to make it hard to get as much testing as you'd like and (2) conceptually I don't think it's reasonable to make managed installs special in this way. For comparison, |
This one is separate from "only willing to use managed installs", though that is a known issue with shebang handling (#91). It's probably two issues here, the crash when it fails to install, and the lack of fallback to an unmanaged runtime when there's no shebang (which is how we ended up in the auto-install path to begin with).
Perhaps true, but existing installs simply don't have the metadata we need to make consistent decisions. We can infer some of it for our own runtimes, but I also don't want to give "PythonCore" an unfair advantage (a fair advantage, on the other hand...). There's going to be two tiers regardless, and we can only create a third, we can't remove any. |
I'm rather uncomfortable about the auto-install behaviour. Can you point me at the documentation of that feature, so that I don't make comments based on a misunderstanding of what's going on? My initial (under-informed) thoughts, though are:
In particular, if I have Python 3.14 installed as my default Python, I would not want running a script that had a Footnotes |
Correct, scripts without a shebang should use any existing install (including an unmanaged one), and so it's extremely unlikely for an unintended install to happen automatically (unless there are no installs at all).
The functionality for this is kinda there, but searching for the script metadata is currently disabled (or not implemented - I implemented it once but can't remember if I left in it there or not).
Prepare to be surprised, I guess 😄 That one should definitely do an install for you, based on the first install in the default feed that offers the There is a documentation gap, though. It would be in the shebangs section, but currently isn't. python/cpython#133928 |
Yeah, this has the potential to be surprising. I expect once people are surprised once then they'll set the configuration to fix their default tag and forget about it (and then complain that they don't have 3.15 when they want it), but maybe the fact that the install isn't silent will be enough? |
Sorry, I'm going to say this is way worse than "surprising". It'll be rare, probably very rare, but it'll be nasty for anyone it hits.
Problem is, seeing it isn't enough, you have to know what to do to fix the problem (in fact, you have to know enough to realise that it is a problem!) If it were me, I'd probably spot it and frantically start hitting Ctrl-C to make it stop, causing more of a mess than just letting it run would have done 🙁 Could we check, and if the installation would change the default version, stop and prompt - "Running this script will require setting your default Python version to 3.15 - are you sure? [y/N]" (note, the default is "no").
Hey - are there two Steves, one posting here and one on Discourse? The guy on Discourse is going to hate that last comment 🙂 |
I actually don't mind prompting unconditionally before an automatic install here (well, conditional on the "confirm" setting). I do like the idea of automatic deployments being able to just run the script they rolled out without thinking about whether Python has been installed or not, but the impact to interactive users is probably surprising enough to justify the warning.
I have draft posts open everywhere right now 🤦♂ Not sure if the context switching would be better or worse if we were sitting in the same office! |
Describe the bug
Running a Python script with the new manager installed crashes:
To Reproduce
Steps to reproduce the behavior:
py
launcher..py
in my PATHEXT variable, so running a Python file from the command line works.xxx
runsxxx.py
, via the shebang line.xxx
at the command line again. This now causes the crash shown above.This is reproducible - I can uninstall the manager to get the old behaviour, and reinstall it to get the crash.
Expected behavior
The command
xxx
runsxxx.py
, exactly as under the oldpy
launcher.Additional context
I don't have file associations for
.py
files. They appear to have been removed at some point in the various modifications I made to try out the new manager previously. I did "associate".py
files wih Python via the explorer GUI, but I don't know where that information is recorded these days (it's clearly not in the registry, see the output of ftype and assoc below).❯ cmd /c ftype Python.File
File type 'Python.File' not found or no open command associated with it.
❯ cmd /c assoc .py
File association not found for extension .py
Log file:
Note that the script itself has no shebang line. It's a 5-line Python script with no dependencies apart from the stdlib.
The text was updated successfully, but these errors were encountered: