Skip to content

Commit 0de7bb9

Browse files
obcopybara-github
authored andcommitted
Don't resolve symlinks for --sandbox_base
On macOS BigSur, the sandbox-exec command behaves slightly different than on Catalina when firm links are present. Resolving symlinks can prevent the sandbox for allowing write operations to the sandbox base. This effectively reverts a piece of 656a0ba, namely: > When using --experimental_sandbox_base, ensure that symlinks in the path are > resolved. Before this, you had to check whether on your system /dev/shm is a > symlink to /run/shm and then use that instead. Now it no longer matters, as > symlinks are resolved. See bazelbuild#13766 for full details. Closes bazelbuild#13984. PiperOrigin-RevId: 422319807
1 parent 07812ff commit 0de7bb9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/com/google/devtools/build/lib/sandbox/SandboxModule.java

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ private static Path computeSandboxBase(SandboxOptions options, CommandEnvironmen
126126
env.getRuntime().getProductName(),
127127
Fingerprint.getHexDigest(env.getOutputBase().toString()));
128128
FileSystem fileSystem = env.getRuntime().getFileSystem();
129+
if (OS.getCurrent() == OS.DARWIN) {
130+
// Don't resolve symlinks on macOS: See https://github.com/bazelbuild/bazel/issues/13766
131+
return fileSystem.getPath(options.sandboxBase).getRelative(dirName);
132+
}
129133
Path resolvedSandboxBase = fileSystem.getPath(options.sandboxBase).resolveSymbolicLinks();
130134
return resolvedSandboxBase.getRelative(dirName);
131135
}

0 commit comments

Comments
 (0)