diff --git a/main.go b/main.go index 4ba8cbe..5396fa4 100644 --- a/main.go +++ b/main.go @@ -2058,7 +2058,7 @@ To install Go, see: https://go.dev/doc/install return errJustExit(1) } if err := json.Unmarshal(out, &cache.GoEnv); err != nil { - return err + return fmt.Errorf(`cannot unmarshal from "go env -json": %w`, err) } cache.GOGARBLE = os.Getenv("GOGARBLE") if cache.GOGARBLE != "" { diff --git a/shared.go b/shared.go index d3c3ab5..578ee0f 100644 --- a/shared.go +++ b/shared.go @@ -64,14 +64,14 @@ func loadSharedCache() error { startTime := time.Now() f, err := os.Open(filepath.Join(sharedTempDir, "main-cache.gob")) if err != nil { - return fmt.Errorf(`cannot open shared file, this is most likely due to not running "garble [command]"`) + return fmt.Errorf(`cannot open shared file: %v; did you run "garble [command]"?`, err) } defer func() { debugf("shared cache loaded in %s from %s", debugSince(startTime), f.Name()) }() defer f.Close() if err := gob.NewDecoder(f).Decode(&cache); err != nil { - return err + return fmt.Errorf("cannot decode shared file: %v", err) } return nil } diff --git a/testdata/scripts/basic.txt b/testdata/scripts/basic.txt index cec5446..c6ec453 100644 --- a/testdata/scripts/basic.txt +++ b/testdata/scripts/basic.txt @@ -29,7 +29,7 @@ stdout 'unknown' # Check that we fail if the user used "go build -toolexec garble" instead of "garble build" ! go build -toolexec=garble -o=main$exe garble_main.go -stderr 'not running "garble \[command\]"' +stderr 'run "garble \[command\]"' # Also check that the binary is reproducible. # No packages should be rebuilt either, thanks to the build cache. diff --git a/testdata/scripts/help.txt b/testdata/scripts/help.txt index 884dcf2..bd819ab 100644 --- a/testdata/scripts/help.txt +++ b/testdata/scripts/help.txt @@ -75,7 +75,7 @@ stderr 'must precede command, like: garble -seed=random build \./pkg' [!windows] ! garble /does/not/exist/compile [windows] ! garble C:\does\not\exist\compile -stderr 'not running "garble \[command\]"' +stderr 'run "garble \[command\]"' # Test the version command. Note that test binaries exclude VCS build info, # and we reuse the test binary for garble itself, so that's missing.