authorgravatar for achan1989@gmail.comachan1989 <achan1989@gmail.com> 2025-01-30 13:10:17+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-01-30 14:10:17+01:00
logf82d7e87a3c640f55714c92c5606d84c13311d78
treefdfef8457464e8c1fec4f31c23e699b90f10052d
parenta3ee5215bba9119d8ab645b0cefee1d026816e13
signaturebadge-check Signed by PGP key B5690EEEBB952194

main: better error message if the global cache dir is unusable

Fixes #19400

1 files changed, 9 insertions(+), 1 deletions(-)

src/main.zig+9-1
......@@ -5002,8 +5002,16 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
50025002
50035003 var global_cache_directory: Directory = l: {
50045004 const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena);
5005 const dir = fs.cwd().makeOpenPath(p, .{}) catch |err| {
5006 const base_msg = "unable to open or create the global Zig cache at '{s}': {s}.{s}";
5007 const extra = "\nIf this location is not writable then consider specifying an " ++
5008 "alternative with the ZIG_GLOBAL_CACHE_DIR environment variable or the " ++
5009 "--global-cache-dir option.";
5010 const show_extra = err == error.AccessDenied or err == error.ReadOnlyFileSystem;
5011 fatal(base_msg, .{ p, @errorName(err), if (show_extra) extra else "" });
5012 };
50055013 break :l .{
5006 .handle = try fs.cwd().makeOpenPath(p, .{}),
5014 .handle = dir,
50075015 .path = p,
50085016 };
50095017 };