Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit 2125c9e

Browse files
author
Nathan Potter
authored
Ensure code-server cache path is mountable on MacOS (#216)
1 parent 8195b9e commit 2125c9e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

codeserver.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ import (
2424
func loadCodeServer(ctx context.Context) (string, error) {
2525
start := time.Now()
2626

27-
cachePath := filepath.Join(os.TempDir(), "sail-code-server-cache/code-server")
27+
var cachePath string
28+
const codeServerPathSuffix = "sail-code-server-cache/code-server"
29+
// MacOS maps os.TempDir() to `/var/folders/...`, which isn't shared with the docker
30+
// system since docker tries to comply with Apple's filesystem sandbox guidelines, so
31+
// default to `/tmp` when on MacOS.
32+
//
33+
// See:
34+
// https://stackoverflow.com/questions/45122459/docker-mounts-denied-the-paths-are-not-shared-from-os-x-and-are-not-known
35+
switch runtime.GOOS {
36+
case "darwin":
37+
cachePath = filepath.Join("/tmp", codeServerPathSuffix)
38+
default:
39+
cachePath = filepath.Join(os.TempDir(), codeServerPathSuffix)
40+
}
2841

2942
// downloadURLPath stores the download URL, so we know whether we should update
3043
// the binary.

0 commit comments

Comments
 (0)