On aarch64-darwin, Go's os/user.Current() performs a C library / system call that does not respect the $HOME environment variable. Since modctl version (like all cobra commands) calls config.NewRoot() → user.Current() → filepath.Join(user.HomeDir, ".modctl"), a ~/.modctl directory is created using the system-level home directory rather than the $HOME override.
This is particularly problematic in test environments where $HOME is set to a temporary directory, the actual home directory is still used, leading to unexpected filesystem side effects or permission errors.
Maybe replacing os/user.Current() with os.UserHomeDir() in pkg/config/root.go, which reads $HOME first is a better solution?
On aarch64-darwin, Go's
os/user.Current()performs a C library / system call that does not respect the$HOMEenvironment variable. Sincemodctl version(like all cobra commands) callsconfig.NewRoot()→user.Current()→filepath.Join(user.HomeDir, ".modctl"), a~/.modctldirectory is created using the system-level home directory rather than the$HOMEoverride.This is particularly problematic in test environments where
$HOMEis set to a temporary directory, the actual home directory is still used, leading to unexpected filesystem side effects or permission errors.Maybe replacing
os/user.Current()withos.UserHomeDir()in pkg/config/root.go, which reads$HOMEfirst is a better solution?