ReviewOS

also looking at this

pantry-pm/pantry

fix(install): keep .env-inferred services out of pantry.lock

#254
Merged glennmichael123 wants to merge fix/253-env-deps-lockfile into main
4 files +286 -70
packages/zig/src/cli/commands/install/helpers.zigmodified+13-1
Changes to packages/zig/src/cli/commands/install/helpers.zig
@@ -652,7 +652,19 @@ pub fn canSkipFromLockfile(
652652 if (!found) return false;
653653 }
654654
655 // Check if destination directory actually exists (use stack buffer + access instead of openDir)
655 return isPackageInstalled(proj_dir, modules_dir, clean_name);
656}
657
658/// Is this package present and usable under `proj_dir/modules_dir`?
659///
660/// The half of `canSkipFromLockfile` that does not consult the lock, for the
661/// packages that are deliberately not in it: a service inferred from `.env`
662/// is installed but never locked (#253), so the lock cannot answer whether
663/// this install still has work to do.
664pub fn isPackageInstalled(proj_dir: []const u8, modules_dir: []const u8, dep_name: []const u8) bool {
665 const clean_name = resolvePackageAlias(normalizePackageName(dep_name));
666 // Stack buffer + access instead of openDir: this runs per dependency on
667 // the fast path.
656668 var dest_buf: [std.fs.max_path_bytes]u8 = undefined;
657669 const dest_dir = std.fmt.bufPrint(&dest_buf, "{s}/{s}/{s}", .{ proj_dir, modules_dir, clean_name }) catch return false;
658670 io_helper.accessAbsolute(dest_dir, .{}) catch return false;