Skip to content

fix(install): avoid creating profiles when removing Claude shim - #168

Merged
codeyevsky merged 1 commit into
solongate:mainfrom
Nelmad:fix/125-avoid-creating-profile-on-shim-removal
Oct 27, 2026
Merged

codeyevsky merged 1 commit into
solongate:mainfrom
Nelmad:fix/125-avoid-creating-profile-on-shim-removal

Conversation

@Nelmad

@Nelmad Nelmad commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

On Windows, RemoveClaudeShim uses the path returned by $PROFILE.CurrentUserAllHosts even when the profile does not exist; non-Windows targets are already filtered by Exists. When the profile is missing, writeShimBlock falls through to MkdirAll and WriteFile, creating an empty profile and any missing parent directories.

Return without writing only when os.ReadFile reports a missing file and the replacement block is empty. Add two t.TempDir regression tests covering an existing parent directory and missing parent directories. Installation still creates missing files/directories, and existing tests cover replacement/idempotence and preserving unrelated content during removal.

Fixes #125.

Validation on macOS arm64 with Go 1.26.10:

  • Both new tests failed on the original production code, then passed with the fix.
  • All 13 shim-related tests passed.
  • go test -count=1 -race ./install/ and go vet ./... passed from packages/core.
  • The CI gofmt check and git diff --check passed.
  • Full core race tests had five failures in config/health; all five also occur on clean baseline b2b4a54632ce8a7aa469305335fb51161f4d2802.
  • scripts/sg-unit-check.sh passed guard, policy and shared, then stopped in packages/sandbox at TestDarwinPreviewDenyList and TestCanonicalFormsDeduplicates on this macOS host. The latter compares /var/folders with /private/var/folders. The same failures occur on the clean baseline. Later packages in the script were not reached; core was run directly instead.

Checks used temporary HOME directories and explicit Go caches. Manual real-agent check: not performed; validation was limited to isolated tests without installing SolonGate or modifying real agent settings. Windows/PowerShell execution remains unverified. The regression tests exercise the platform-independent helper with temporary files.

Skip writes when removing a shim from a missing profile, so removal does
not create an empty profile or its parent directories. Keep installation
behavior unchanged and cover both missing-file cases with regression tests.

Signed-off-by: Nelmad <17722412+Nelmad@users.noreply.github.com>
@codeyevsky
codeyevsky merged commit 9326a34 into solongate:main Oct 27, 2026
34 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.

install: RemoveClaudeShim creates an empty PowerShell profile on Windows when none existed

2 participants