Skip to content

Remove dead ConfigPath variable in pkg/config/config.go (also uses HOME which is empty on Windows) #444

@hazelmayank

Description

@hazelmayank

Description

pkg/config/config.go declares a package-level ConfigPath variable that
is never read anywhere in the codebase, and would be broken on Windows if
anything did try to use it.

// pkg/config/config.go
var (
    InsecureTLS bool = false
    CaCertPaths string
    Verbose     bool = false

    ConfigPath = filepath.Join(os.Getenv("HOME"), ".microcks-cli", "config.yaml")
)

Why it's dead

Grep for config.ConfigPath\b across the repo: every match resolves to
globalClientOpts.ConfigPath or opts.ConfigPath — both of which are
fields on the ClientOptions struct, not the package variable.

The actual default config path comes from DefaultLocalConfigPath() in
pkg/config/localconfig.go, which uses os.UserHomeDir() correctly.

Why it would also be wrong on Windows

os.Getenv("HOME") returns "" on Windows by default — Windows uses
USERPROFILE. So if anything ever started using config.ConfigPath, it
would silently produce a broken relative path like \.microcks-cli\config.yaml
on Windows.

The cross-platform-safe alternative is os.UserHomeDir(), which is what
localconfig.go already uses.

Proposed fix

Delete the unused ConfigPath variable. No replacement needed — the
real config path is computed by DefaultLocalConfigPath().

This also lets us drop the path/filepath import from config.go (it's
only used by this one line).

Impact

Zero behavioral change. The CLI never reads this variable; removing it is
a pure cleanup.

Environment

  • Branch: master (development version 1.0.3)
  • File: pkg/config/config.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions