Skip to content

Commit 71f9301

Browse files
authored
Merge pull request #12487 from NixOS/mergify/bp/2.24-maintenance/pr-12481
resolveLookupPathPath(): Fix caching of negative lookups (backport #12481)
2 parents d3a52c2 + b706642 commit 71f9301

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/libexpr/eval-settings.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Strings EvalSettings::getDefaultNixPath()
5757
{
5858
Strings res;
5959
auto add = [&](const Path & p, const std::string & s = std::string()) {
60-
if (pathAccessible(p)) {
60+
if (std::filesystem::exists(p)) {
6161
if (s.empty()) {
6262
res.push_back(p);
6363
} else {

src/libexpr/eval.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,8 +3084,11 @@ std::optional<std::string> EvalState::resolveLookupPathPath(const LookupPath::Pa
30843084
auto i = lookupPathResolved.find(value);
30853085
if (i != lookupPathResolved.end()) return i->second;
30863086

3087-
auto finish = [&](std::string res) {
3088-
debug("resolved search path element '%s' to '%s'", value, res);
3087+
auto finish = [&](std::optional<std::string> res) {
3088+
if (res)
3089+
debug("resolved search path element '%s' to '%s'", value, *res);
3090+
else
3091+
debug("failed to resolve search path element '%s'", value);
30893092
lookupPathResolved.emplace(value, res);
30903093
return res;
30913094
};
@@ -3137,9 +3140,7 @@ std::optional<std::string> EvalState::resolveLookupPathPath(const LookupPath::Pa
31373140
}
31383141
}
31393142

3140-
debug("failed to resolve search path element '%s'", value);
3141-
return std::nullopt;
3142-
3143+
return finish(std::nullopt);
31433144
}
31443145

31453146

0 commit comments

Comments
 (0)