Skip to content

fix(config): use path/filepath for OS-correct path separators#442

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
hazelmayank:fix/config-filepath-join
Jul 20, 2026
Merged

fix(config): use path/filepath for OS-correct path separators#442
Harsh4902 merged 1 commit into
microcks:masterfrom
hazelmayank:fix/config-filepath-join

Conversation

@hazelmayank

@hazelmayank hazelmayank commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the path package with path/filepath in pkg/config/localconfig.go
so the CLI builds filesystem paths with the OS-correct separator.

Fixes #441 .

Background

The Go standard library splits path manipulation across two packages:

  • path — always uses /. Meant for URLs and slash-separated paths.
  • path/filepath — uses the OS-specific separator. Meant for filesystem paths.

localconfig.go was using path.Join / path.Dir to construct filesystem
paths. On Windows this produced mixed-separator paths because os.UserHomeDir()
returns backslashes but path.Join then appended with forward slashes.

Changes

pkg/config/localconfig.go:

  • Replaced import "path" with import "path/filepath".
  • Replaced 3 path.Join calls with filepath.Join (lines 112, 133, 142).
  • Replaced 2 path.Dir calls with filepath.Dir (lines 158, 410).

No other files needed changes — path was only used in this file for filesystem
path construction.

Before / After (Windows 11)

Before:
WhatsApp Image 2026-05-27 at 00 38 06



> microcks --help
      --config string   Path to Microcks config (default "C:\Users\<USER>/.config/microcks/config")
> microcks context
2026/05/27 00:35:59 No contexts defined in C:\Users\<USER>/.config/microcks/config

After:
image



> microcks --help
      --config string   Path to Microcks config (default "C:\Users\<USER>\.config\microcks\config")
> microcks context
2026/05/27 00:35:59 No contexts defined in C:\Users\<USER>\.config\microcks\config

Linux / macOS output is unchanged.

Test plan

  • go build . succeeds on Windows.
  • microcks --help shows all-backslash default config path on Windows.
  • microcks context shows all-backslash path on Windows.
  • CI passes on all platforms.

Related

This is in the same family as #352 / PR #353 (Windows absolute path parsing).

Signed-off-by: hazelmayank <mayankjeefinal@gmail.com>
@Vaishnav88sk

Copy link
Copy Markdown

This change is required. path is for slash-separated paths, while this code is building filesystem paths. Using filepath here is the correct fix and improves Windows behavior without changing Unix behavior.

Minimal change, correct scope, no further changes needed. LGTM.
@Harsh4902

@Harsh4902 Harsh4902 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Harsh4902
Harsh4902 merged commit a3ebb18 into microcks:master Jul 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default config path uses forward slashes on Windows, producing mixed-separator paths

3 participants