libstore/static-init: don't crash if nixBinDir exists but isn't accessible
In d2696cdd¹, libstore was made to prioritize NIX_BIN_DIR/nix (over
/proc/self/exe) if it exists. But `pathExists()` throws an exception if
lstat() returns any error other than non-existence.
Because this check happens in libstore's Settings constructor for the
static-initialized global `nix::Settings`, this case would abort Lix
well before main().
[1]: d2696cdd1e
Change-Id: I62e44c8a33b28c234900df3e4790c1badefee358
This commit is contained in:
@@ -116,7 +116,7 @@ Settings::Settings()
|
|||||||
you'll want to improve `getSelfExe()` to work on your platform.
|
you'll want to improve `getSelfExe()` to work on your platform.
|
||||||
*/
|
*/
|
||||||
std::string nixExePath = nixBinDir + "/nix";
|
std::string nixExePath = nixBinDir + "/nix";
|
||||||
if (!pathExists(nixExePath)) {
|
if (!pathAccessible(nixExePath)) {
|
||||||
nixExePath = getSelfExe().value_or("nix");
|
nixExePath = getSelfExe().value_or("nix");
|
||||||
}
|
}
|
||||||
buildHook.setDefault(Strings {
|
buildHook.setDefault(Strings {
|
||||||
|
|||||||
Reference in New Issue
Block a user