diff --git a/src/bun.zig b/src/bun.zig index f468a7d7a8..73814b39b2 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -773,7 +773,7 @@ pub fn openDir(dir: std.fs.Dir, path_: [:0]const u8) !std.fs.IterableDir { const res = try sys.openDirAtWindowsA(toFD(dir.fd), path_, true, false).unwrap(); return std.fs.IterableDir{ .dir = .{ .fd = fdcast(res) } }; } else { - const fd = try sys.openat(dir.fd, path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | 0, 0).unwrap(); + const fd = try sys.openat(dir.fd, path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | std.os.O.RDONLY, 0).unwrap(); return std.fs.IterableDir{ .dir = .{ .fd = fd } }; } } @@ -783,7 +783,7 @@ pub fn openDirA(dir: std.fs.Dir, path_: []const u8) !std.fs.IterableDir { const res = try sys.openDirAtWindowsA(toFD(dir.fd), path_, true, false).unwrap(); return std.fs.IterableDir{ .dir = .{ .fd = fdcast(res) } }; } else { - const fd = try sys.openatA(dir.fd, path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | 0, 0).unwrap(); + const fd = try sys.openatA(dir.fd, path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | std.os.O.RDONLY, 0).unwrap(); return std.fs.IterableDir{ .dir = .{ .fd = fd } }; } } @@ -793,7 +793,7 @@ pub fn openDirAbsolute(path_: []const u8) !std.fs.Dir { const res = try sys.openDirAtWindowsA(invalid_fd, path_, true, false).unwrap(); return std.fs.Dir{ .fd = fdcast(res) }; } else { - const fd = try sys.openA(path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | 0, 0).unwrap(); + const fd = try sys.openA(path_, std.os.O.DIRECTORY | std.os.O.CLOEXEC | std.os.O.RDONLY, 0).unwrap(); return std.fs.Dir{ .fd = fd }; } } diff --git a/src/install/install.zig b/src/install/install.zig index 4664db16a6..abf17efc8c 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -7258,9 +7258,11 @@ pub const PackageManager = struct { const cwd = std.fs.cwd(); var node_modules_folder = cwd.openIterableDir("node_modules", .{}) catch brk: { skip_verify_installed_version_number = true; - bun.sys.mkdir("node_modules", 0).throw() catch |err| { - Output.prettyErrorln("error: {s} creating node_modules folder", .{@errorName(err)}); - Global.crash(); + bun.sys.mkdir("node_modules", 0o755).throw() catch |err| { + if (err != error.EEXIST) { + Output.prettyErrorln("error: {s} creating node_modules folder", .{@errorName(err)}); + Global.crash(); + } }; break :brk cwd.openIterableDir("node_modules", .{}) catch |err| { Output.prettyErrorln("error: {s} opening node_modules folder", .{@errorName(err)});