builtins.readDir: fix nix error trace on filesystem errors
Motivation
builtins.readDir: fix nix error trace on filesystem errors
Before:
nix-env % ./src/nix/nix eval --impure --expr 'let f = builtins.readDir "/nix/store/39z5zpb72qrnxl832nwphcd4ihfhix3j-hello-2.12.1/foobar"; in f' --show-trace
error: filesystem error: directory iterator cannot open directory: No such file or directory [/nix/store/39z5zpb72qrnxl832nwphcd4ihfhix3j-hello-2.12.1/foobar]
After:
error:
… while calling the 'readDir' builtin
at «string»:1:9:
1| let f = builtins.readDir "/nix/store/39z5zpb72qrnxl832nwphcd4ihfhix3j-hello-2.12.1/foobar"; in f
| ^
error: reading directory content failed: filesystem error: directory iterator cannot open directory: No such file or directory [/nix/store/39z5zpb72qrnxl832nwphcd4ihfhix3j-hello-2.12.1/foobar]
Context
Priorities and Process
Add :+1: to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
There are sure more errors like this in here. I see for example a few "fs::is_$type", which can also throw errors.
Now that @Ericson2314 is mentioning it the SysError one might actually not be the right one to use for rethrowing
This is now mergeable.
I would convert to a nix exception in PosixSourceAccessor::readDirectory, and then make the catch-rethrow in the evaluator just add the position info.
We want all SourceAccessors to throw the same sorts of exceptions, I think.
@mergifyio rebase
rebase
❌ Unable to rebase: user roberth is unknown.
Please make sure roberth has logged in Mergify dashboard.
@mergify rebase
rebase
✅ Branch has been successfully rebased
@Ericson2314 ok. This is better. I also fixed a similar issue in :lf, which would make the repl crash.
Fixed following the suggestions of @Ericson2314 and also fixed a similar repl crash.
@Ericson2314 applied
This pull request has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/nix-2-25-released/55994/1