fix(tvix): distinguish search- and relative path resolution errors

Failures to resolve a nix search path lookup in angle brackets can be
caught using tryEval (if it reaches the runtime). Resolving relative
paths (either to the current directory or the current user's home) can
never be caught, even if they happen inside a thunk at runtime (which is
currently the case for home-relative paths).

Change-Id: I7f73221df66d82a381dd4063358906257826995a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7025
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
sterni 2022-10-21 00:52:36 +02:00 committed by clbot
parent 5753fc14f5
commit 64bb501de1
4 changed files with 19 additions and 11 deletions

View file

@ -115,7 +115,7 @@ impl<'observer> Compiler<'observer> {
Some(dir) if cfg!(target_arch = "wasm32") || dir.is_absolute() => Ok(dir),
_ => {
let current_dir = std::env::current_dir().map_err(|e| Error {
kind: ErrorKind::PathResolution(format!(
kind: ErrorKind::RelativePathResolution(format!(
"could not determine current directory: {}",
e
)),
@ -290,7 +290,7 @@ impl Compiler<'_> {
if raw_path.len() == 2 {
return self.emit_error(
node,
ErrorKind::PathResolution("Empty <> path not allowed".into()),
ErrorKind::NixPathResolution("Empty <> path not allowed".into()),
);
}
let path = &raw_path[1..(raw_path.len() - 1)];