authorgravatar for carl@astholm.seCarl Åstholm <carl@astholm.se> 2025-03-04 14:56:18+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-03-04 17:27:21-05:00
log8363b951788a666802d6bbd6364eb973e2dbc09a
treec9f89f1e0b6841f2304eabfb337e79aefbab67bb
parent711b0fef58571761386fd8dcd8b9ea3df2283200

Fix "dependency path outside project" error for nested local path dependencies

Closes #23076

1 files changed, 11 insertions(+), 3 deletions(-)

src/Package/Fetch.zig+11-3
......@@ -331,9 +331,17 @@ pub fn run(f: *Fetch) RunError!void {
331331 // prefix of "p/$hash/".
332332 const prefix_len: usize = if (f.job_queue.read_only) 0 else "p/".len;
333333 const parent_sub_path = f.parent_package_root.sub_path;
334 const end = std.mem.indexOfScalarPos(u8, parent_sub_path, prefix_len, fs.path.sep) orelse
335 parent_sub_path.len;
336 const expected_prefix = parent_sub_path[prefix_len..end];
334 const end = find_end: {
335 if (parent_sub_path.len > prefix_len) {
336 // Use `isSep` instead of `indexOfScalarPos` to account for
337 // Windows accepting both `\` and `/` as path separators.
338 for (parent_sub_path[prefix_len..], prefix_len..) |c, i| {
339 if (std.fs.path.isSep(c)) break :find_end i;
340 }
341 }
342 break :find_end parent_sub_path.len;
343 };
344 const expected_prefix = parent_sub_path[0..end];
337345 if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) {
338346 return f.fail(
339347 f.location_tok,