Skip to content

Commit e0f4a8b

Browse files
committed
do best-effort to have Nix system initialized (needed for tests or other direct devbox library callers)
1 parent dab7df1 commit e0f4a8b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/nix/nix.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ func ExperimentalFlags() []string {
121121
// TODO: rename to System
122122
func MustGetSystem() string {
123123
if cachedSystem == "" {
124-
panic("MustGetSystem called before being initialized by System")
124+
// For internal calls (during tests), this may not be initialized properly
125+
// so do a best-effort attempt to initialize it.
126+
_, err := System()
127+
if err != nil {
128+
panic("MustGetSystem called before being initialized by System")
129+
}
125130
}
126131
return cachedSystem
127132
}

0 commit comments

Comments
 (0)