Skip to content

fix(windows): selfContained detection false positive from subos shim#301

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/selfcontained-detection-windows
May 22, 2026
Merged

fix(windows): selfContained detection false positive from subos shim#301
Sunrisepeak merged 1 commit into
mainfrom
fix/selfcontained-detection-windows

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • Bug: On Windows, running xlings from subos/current/bin/xlings.exe (shim) triggers false selfContained detection, setting homeDir to subos/current/ instead of ~/.xlings/. This breaks global installs, version tracking, and shim creation.
  • Root cause: Windows shims are hardlinks/copies (not symlinks), so get_executable_path() returns the shim path. The subos directory has both .xlings.json and bin/xlings.exe, matching the selfContained pattern.
  • Fix: Exclude candidates whose parent directory is named subos — real selfContained packages are never nested under subos/.
  • Version: bumped to 0.4.39

Design doc

See .agents/docs/2026-05-22-selfcontained-detection-windows-bug.md

Test plan

  • Windows CI: xlings install <pkg> -g && <pkg> --version should pass
  • Linux/macOS: no behavior change (shims are symlinks, don't hit this path)
  • selfContained mode: running from extracted release package still works

@Sunrisepeak Sunrisepeak force-pushed the fix/selfcontained-detection-windows branch from 783b7a5 to 7381d6a Compare May 22, 2026 03:03
…path

On Windows, shims in subos/current/bin/ are hardlinks or copies (not
symlinks like Unix).  get_executable_path() returns the shim path, and
the parent-of-parent subos directory has both .xlings.json and
bin/xlings.exe — falsely matching the selfContained detection pattern.

This caused homeDir to be set to the subos directory instead of
~/.xlings, breaking all subsequent operations (versions DB, workspace,
shim creation paths).

Fix: use `if constexpr (platform::OS_NAME == "windows")` to add a
compile-time guarded content check — verify that the candidate
.xlings.json contains both "version" and "activeSubos" fields (written
by `self install`).  Subos .xlings.json only has {"workspace":{}}, so
the dual-field check reliably distinguishes the two cases.  Linux/macOS
pay zero overhead since shim symlinks resolve correctly.

Also replaces the #ifdef _WIN32 for binary name detection with a
constexpr ternary on platform::OS_NAME, converging platform branching
into the platform module.

Bump version to 0.4.39.
@Sunrisepeak Sunrisepeak force-pushed the fix/selfcontained-detection-windows branch from 7381d6a to a8c88f8 Compare May 22, 2026 03:22
@Sunrisepeak Sunrisepeak merged commit 76a087b into main May 22, 2026
3 checks passed
@Sunrisepeak Sunrisepeak deleted the fix/selfcontained-detection-windows branch May 22, 2026 03:36
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.

1 participant