@@ -18,6 +18,7 @@ import (
18
18
"github.com/pkg/errors"
19
19
"go.jetpack.io/devbox/internal/boxcli/featureflag"
20
20
"go.jetpack.io/devbox/internal/boxcli/usererr"
21
+ "go.jetpack.io/devbox/internal/redact"
21
22
22
23
"go.jetpack.io/devbox/internal/debug"
23
24
)
@@ -76,15 +77,22 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
76
77
if insecure , insecureErr := IsExitErrorInsecurePackage (err , "" /*installable*/ ); insecure {
77
78
return nil , insecureErr
78
79
} else if err != nil {
79
- return nil , errors .Wrapf (err , "Command: %s" , cmd )
80
+ safeArgs := make ([]string , 0 , len (cmd .Args ))
81
+ for _ , a := range cmd .Args {
82
+ if a == args .FlakeDir {
83
+ a = "<redacted path>"
84
+ }
85
+ safeArgs = append (safeArgs , a )
86
+ }
87
+ return nil , redact .Errorf ("nix command: %s" , redact .Safe (safeArgs ))
80
88
}
81
89
82
90
if err := json .Unmarshal (data , & out ); err != nil {
83
- return nil , errors . WithStack ( err )
91
+ return nil , redact . Errorf ( "unmarshal nix print-dev-env output: %w" , redact . Safe ( err ) )
84
92
}
85
93
86
94
if err = savePrintDevEnvCache (args .PrintDevEnvCachePath , out ); err != nil {
87
- return nil , errors . WithStack ( err )
95
+ return nil , redact . Errorf ( "savePrintDevEnvCache: %w" , redact . Safe ( err ) )
88
96
}
89
97
}
90
98
@@ -175,12 +183,13 @@ func Version() (string, error) {
175
183
cmd := command ("--version" )
176
184
outBytes , err := cmd .Output ()
177
185
if err != nil {
178
- return "" , errors . WithStack ( err )
186
+ return "" , redact . Errorf ( "nix command: %s" , redact . Safe ( cmd ) )
179
187
}
180
188
out := string (outBytes )
181
189
const prefix = "nix (Nix) "
182
190
if ! strings .HasPrefix (out , prefix ) {
183
- return "" , errors .Errorf (`Expected "%s" prefix, but output from nix --version was: %s` , prefix , out )
191
+ return "" , redact .Errorf (`nix command %s: expected %q prefix, but output was: %s` ,
192
+ redact .Safe (cmd ), redact .Safe (prefix ), redact .Safe (out ))
184
193
}
185
194
version = strings .TrimSpace (strings .TrimPrefix (out , prefix ))
186
195
return version , nil
0 commit comments