From 09d51af1615f4b6af74605b73c5d0c7271ac815b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 29 Dec 2021 22:53:30 -0800 Subject: [PATCH] handle AccessDenied when making 'builtin.zig' fill-in --- src/main.zig | 7 +++++-- tests/sessions.zig | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index 0baac98..70c173c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1789,7 +1789,7 @@ pub fn main() anyerror!void { logger.warn("Zig standard library path not specified in zls.json and could not be resolved from the zig executable", .{}); } - if (config.builtin_path == null and config.zig_exe_path != null and config_path != null) { + if (config.builtin_path == null and config.zig_exe_path != null and config_path != null) blk: { const result = try std.ChildProcess.exec(.{ .allocator = allocator, .argv = &.{ @@ -1805,7 +1805,10 @@ pub fn main() anyerror!void { var d = try std.fs.cwd().openDir(config_path.?, .{}); defer d.close(); - const f = try d.createFile("builtin.zig", .{}); + const f = d.createFile("builtin.zig", .{}) catch |err| switch (err) { + error.AccessDenied => break :blk, + else => |e| return e, + }; defer f.close(); try f.writer().writeAll(result.stdout); diff --git a/tests/sessions.zig b/tests/sessions.zig index 530f7ee..59118c5 100644 --- a/tests/sessions.zig +++ b/tests/sessions.zig @@ -111,7 +111,7 @@ fn startZls() !*std.ChildProcess { var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator); process.stdin_behavior = .Pipe; process.stdout_behavior = .Pipe; - process.stderr_behavior = .Inherit; //std.ChildProcess.StdIo.Inherit; + process.stderr_behavior = .Inherit; process.spawn() catch |err| { std.debug.print("Failed to spawn zls process, error: {}\n", .{err});