Skip to content

Commit 787f61d

Browse files
committed
cmd/go: improve handling of tmpdir being noexec
1 parent 5f2fdbe commit 787f61d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cmd/go/internal/work/action.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"context"
1414
"debug/elf"
1515
"encoding/json"
16+
"errors"
1617
"fmt"
1718
"os"
1819
"path/filepath"
@@ -254,7 +255,13 @@ func (b *Builder) Init() {
254255
} else {
255256
tmp, err := os.MkdirTemp(cfg.Getenv("GOTMPDIR"), "go-build")
256257
if err != nil {
257-
base.Fatalf("go: creating work dir: %v", err)
258+
if errors.Is(err, os.ErrPermission) {
259+
base.Fatalf("go: creating work dir: %v.\n"+
260+
"\tRun 'go env -w GOTMPDIR=...' to specify another temporary directory.\n"+
261+
"\tFor more about GOTMPDIR, see 'go help environment'.", err)
262+
} else {
263+
base.Fatalf("go: creating work dir: %v", err)
264+
}
258265
}
259266
if !filepath.IsAbs(tmp) {
260267
abs, err := filepath.Abs(tmp)

0 commit comments

Comments
 (0)