Skip to content

Commit c8f8e5c

Browse files
committed
Revert "nix: improve redacted nix error (#1776)"
This reverts commit 12f2daf.
1 parent 2018568 commit c8f8e5c

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

internal/nix/nix.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/pkg/errors"
1919
"go.jetpack.io/devbox/internal/boxcli/featureflag"
2020
"go.jetpack.io/devbox/internal/boxcli/usererr"
21-
"go.jetpack.io/devbox/internal/redact"
2221

2322
"go.jetpack.io/devbox/internal/debug"
2423
)
@@ -82,22 +81,15 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
8281
if insecure, insecureErr := IsExitErrorInsecurePackage(err, "" /*installable*/); insecure {
8382
return nil, insecureErr
8483
} else if err != nil {
85-
safeArgs := make([]string, 0, len(cmd.Args))
86-
for _, a := range cmd.Args {
87-
if a == args.FlakeDir {
88-
a = "<redacted path>"
89-
}
90-
safeArgs = append(safeArgs, a)
91-
}
92-
return nil, redact.Errorf("nix command: %s", redact.Safe(safeArgs))
84+
return nil, errors.Wrapf(err, "Command: %s", cmd)
9385
}
9486

9587
if err := json.Unmarshal(data, &out); err != nil {
96-
return nil, redact.Errorf("unmarshal nix print-dev-env output: %w", redact.Safe(err))
88+
return nil, errors.WithStack(err)
9789
}
9890

9991
if err = savePrintDevEnvCache(args.PrintDevEnvCachePath, out); err != nil {
100-
return nil, redact.Errorf("savePrintDevEnvCache: %w", redact.Safe(err))
92+
return nil, errors.WithStack(err)
10193
}
10294
}
10395

@@ -188,13 +180,12 @@ func Version() (string, error) {
188180
cmd := command("--version")
189181
outBytes, err := cmd.Output()
190182
if err != nil {
191-
return "", redact.Errorf("nix command: %s", redact.Safe(cmd))
183+
return "", errors.WithStack(err)
192184
}
193185
out := string(outBytes)
194186
const prefix = "nix (Nix) "
195187
if !strings.HasPrefix(out, prefix) {
196-
return "", redact.Errorf(`nix command %s: expected %q prefix, but output was: %s`,
197-
redact.Safe(cmd), redact.Safe(prefix), redact.Safe(out))
188+
return "", errors.Errorf(`Expected "%s" prefix, but output from nix --version was: %s`, prefix, out)
198189
}
199190
version = strings.TrimSpace(strings.TrimPrefix(out, prefix))
200191
return version, nil

0 commit comments

Comments
 (0)