Skip to content

bug: os/user.Current() ignores $HOME, breaks on aarch64-darwin #580

Description

@GBHU753

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions