Skip to content

Fix crash on Windows #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/setup.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ pub fn wizard(allocator: *std.mem.Allocator) !void {
print("Found zig executable '{s}' in PATH.\n", .{path});
} else {
write("Could not find 'zig' in PATH\n");
zig_exe_path = try zinput.askString(allocator, "What is the path to the 'zig' executable you would like to use?", std.fs.MAX_PATH_BYTES);
zig_exe_path = try zinput.askString(allocator,
if (std.builtin.os.tag == .windows)
\\What is the path to the 'zig' executable you would like to use?
\\Note that due to a bug in zig (https://github.com/ziglang/zig/issues/6044),
\\your zig directory cannot contain the '/' character.
else
"What is the path to the 'zig' executable you would like to use?",
std.fs.MAX_PATH_BYTES);
}

const editor = try zinput.askSelectOne("Which code editor do you use?", enum { VSCode, Sublime, Kate, Neovim, Vim8, Emacs, Doom, Other });
Expand Down Expand Up @@ -223,15 +230,17 @@ pub fn findZig(allocator: *std.mem.Allocator) !?[]const u8 {

var it = std.mem.tokenize(env_path, &[_]u8{std.fs.path.delimiter});
while (it.next()) |path| {
if (std.builtin.os.tag == .windows) {
if (std.mem.indexOfScalar(u8, path, '/')) |s| continue;
}
const full_path = try std.fs.path.join(allocator, &[_][]const u8{
path,
zig_exe,
});
defer allocator.free(full_path);

if (!std.fs.path.isAbsolute(full_path)) continue;

// Skip folders named zig

const file = std.fs.openFileAbsolute(full_path, .{}) catch continue;
defer file.close();
const stat = file.stat() catch continue;
Expand Down