On Windows, what strategy should
Command::new use to find executables? Possible search locations include:
- The exe's directory. Traditionally the executable's directory is a kind of application bundle. Binaries are in the root and resources are in subfolders (this also affects default dll loading if not using an rpath equivalent). On the other hand, if that's the wanted behaviour of
Commandthen it's likely that the developer won't want to be running some random other application if, for some reason, it's not where it's supposed to be. And it's easy enough to use
std::env::current_exeto get the exe's directory in that case.
- Path environment variable.
- "App Paths". Applications can register their presence in the registry instead of (or in addition to) using
- System folders (i.e.
C:\Windows). These should already be in
Pathbut if they're not then should they still be searched? Do people generally assume (as now) that
cmdet al will always be found?
Should Rust try to search all these locations? Some? Or should it just stick to the
Path environment variable?
Ideally this would be configurable in some way but even then it's desirable to have sensible defaults. Also assume for the sake of this thread that some implementation details of
Command::new can be changed (or else it's replaced with a different method). This follows on from here in which it was pointed out that there can be security implications with the current behaviour of