Closed TerrorJack closed 2 months ago
What are the affected versions?
directory-1.3.8.4
as shipped in ghc head.
I can also reproduce this with directory-1.3.7.1 from GHC-9.4.8. So it is not related to the OsPath migration.
This appears to be canonical behavior for the Win32 SearchPathW
API:
#include <stdio.h>
#include <windows.h>
int main(void)
{
wchar_t buffer[512] = {0};
if (SearchPathW(NULL, L"", L".exe", 512, buffer, NULL) == 0) {
return GetLastError();
}
printf("%ls\n", buffer);
return 0;
}
This fails with ERROR_INVALID_PARAMETER (87).
Given that the directory
implementation of findExecutable
has always relied on SearchPathW
, this is unlikely a regression and has probably worked this way since the beginning.
I think it is a reasonable feature request though. The SearchPathW
seems to handle other kinds of nonsensical strings just fine, except for the empty string.
On Windows,
findExecutable ""
would throw*** Exception: searchPath: invalid argument (The parameter is incorrect.)
. However, on Linux it simply returnsNothing
. I believe this is a bug and we should align Windows behavior with Linux to also returnNothing
.