diff options
| author | achan1989 <achan1989@gmail.com> | 2025-01-30 13:10:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 14:10:17 +0100 |
| commit | f82d7e87a3c640f55714c92c5606d84c13311d78 (patch) | |
| tree | fdfef8457464e8c1fec4f31c23e699b90f10052d /src/main.zig | |
| parent | a3ee5215bba9119d8ab645b0cefee1d026816e13 (diff) | |
| download | zig-f82d7e87a3c640f55714c92c5606d84c13311d78.tar.gz zig-f82d7e87a3c640f55714c92c5606d84c13311d78.zip | |
main: better error message if the global cache dir is unusable
Fixes #19400
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index 34d610bdd1..a925286c7e 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5002,8 +5002,16 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { var global_cache_directory: Directory = l: { const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena); + const dir = fs.cwd().makeOpenPath(p, .{}) catch |err| { + const base_msg = "unable to open or create the global Zig cache at '{s}': {s}.{s}"; + const extra = "\nIf this location is not writable then consider specifying an " ++ + "alternative with the ZIG_GLOBAL_CACHE_DIR environment variable or the " ++ + "--global-cache-dir option."; + const show_extra = err == error.AccessDenied or err == error.ReadOnlyFileSystem; + fatal(base_msg, .{ p, @errorName(err), if (show_extra) extra else "" }); + }; break :l .{ - .handle = try fs.cwd().makeOpenPath(p, .{}), + .handle = dir, .path = p, }; }; |
