Make sure zig lib path retrieved from zig env is absolute (#799)

This commit is contained in:
Alexandros Naskos 2022-12-02 23:22:35 +02:00 committed by GitHub
parent 6ab2c68355
commit 3ab859a304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -150,9 +150,8 @@ pub fn configChanged(config: *Config, allocator: std.mem.Allocator, builtin_crea
var env = getZigEnv(allocator, exe_path) orelse break :blk;
defer std.json.parseFree(Env, env, .{ .allocator = allocator });
// We know this is allocated with `allocator`, we just steal it!
config.zig_lib_path = env.lib_dir.?;
env.lib_dir = null;
// Make sure the path is absolute
config.zig_lib_path = try std.fs.realpathAlloc(allocator, env.lib_dir.?);
logger.info("Using zig lib path '{s}'", .{config.zig_lib_path.?});
} else {
logger.warn("Zig executable path not specified in zls.json and could not be found in PATH", .{});