nushell: Nushell no longer respects file associations on Windows
Describe the bug
e.g. given some x.py and a file association of
>ASSOC .py
.py=Python.File
>FTYPE Python.File
Python.File="C:\Windows\py.exe" "%L" %*
How to reproduce
〉x.py --help
Error: nu::shell::external_command (link)
× External command failed
╭─[entry #4:1:1]
1 │ x.py --help
· ──┬─
· ╰── did you mean 'cp'?
╰────
help: program not found
〉./x.py --help
Error: nu::shell::external_command (link)
× External command failed
╭─[entry #5:1:1]
1 │ ./x.py --help
· ───┬──
· ╰── can't run executable
╰────
help: %1 is not a valid Win32 application. (os error 193)
Expected behavior
The file should be run using the file association. This is what happened when running via a cmd /c host shell for execution.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.67.0 |
| branch | |
| commit_hash | 91976988f032276ca48faff2d1ac13c079eda836 |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.63.0 (4b91a6ea7 2022-08-08) |
| rust_channel | stable-x86_64-pc-windows-msvc |
| cargo_version | cargo 1.63.0 (fd9c4297c 2022-07-01) |
| pkg_version | 0.67.0 |
| build_time | 2022-08-17 15:20:56 +00:00 |
| build_rust_channel | release |
| features | database, dataframe, default, trash, which, zip |
| installed_plugins |
Additional context
The Windows documentation for file types is https://docs.microsoft.com/en-us/windows/win32/shell/fa-file-types. If I’m reading this right, in order to read the file associations you need to read the registry directly.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (18 by maintainers)
Also of note;
./x.pyshould run the script in the same terminal;start x.pyopens it in a new terminal window.So we’re kindof both right, in that it is the which path executing it, but that the behavior changed after that PR when updating the dependency.
That said, the “proper” behavior is probably to
assoc/ftype. For example, try “running” a.htmlin cmd;ftypesaysiexplore.exebut it will be your actual browser choice.The point is to “act like a shell” in terms of executing files; matching the behavior of cmd and pwsh in launching files is probably better than being “pure” and only launching directly-executables or PATHEXT executables.