Repository navigation
feat(xself): implement self uninstall (-y / --keep-data / --dry-run) - #261
Merged
Merged
Conversation
…e fixes) End-to-end CI verification of the full chain that landed across recent xlings + xim-pkgindex work: xim-pkgindex bumps from 83044b5 (pre-#108) to 19f4383 (main HEAD), now includes: * #110/#111: namespace all bare-name deps (cmake/ninja/xmake/gcc/ binutils/openssl/d2x → xim: prefix), removes dual-mount ambiguity * #116: split xim:gcc-runtime as a standalone xpkg (~25 MB) containing libstdc++/libgcc_s/libgomp/etc — vs full xim:gcc compiler (~1.1 GB) * #117: switch ninja/node/mdbook from xim:gcc to xim:gcc-runtime, so consumer rpath closure pulls only the runtime libs they need * #118: gcc-runtime declares `exports.runtime.libdirs = { "lib64" }` (correct schema field, was incorrectly `abi = {...}` in #116) Pairs with xlings's: * 0.4.13 release: patchelf op order fix (no compact-ELF corruption) * post-merge PR #259: load_project_config_ falls through to XLINGS_PROJECT_DIR env after a projectScope:false skip (without this fix, gcc-specs-config shim spawned from gcc.config hook couldn't resolve its workspace version because the cwd traversal hit the xlings repo's own projectScope:false .xlings.json) Together these enable E2E-05 (Fixed Project Scenarios) to exercise the full predicate-driven elfpatch + script-as-runtime-dep flow on Linux without the workarounds the previous pin (83044b5) was sidestepping. If CI is green, the temporary pin can stay (now bumped) — or be removed entirely once we trust both sides' main to evolve in lockstep.
Closes the long-standing gap where `xlings remove xim:xlings` refuses
single-version self-removal and routes the user to `self uninstall`,
but `self uninstall` didn't exist — the dispatcher silently fell
through to help and exited 0, making the command a footgun for
automation scripts.
## Semantics (vs `xlings remove xim:xlings`)
- `xlings remove xim:xlings@VER` removes a single version; refuses
when only one xlings version is installed (single-version guard
pointing the user here)
- `xlings self uninstall` is the escape hatch: removes the entire
XLINGS_HOME (bin/, subos/, data/, config/, .xlings.json + the
home dir itself), all installed packages, all subos. Lets the
user fully tear down xlings even with a single version present.
## CLI
xlings self uninstall [-y | --yes] [--keep-data] [--dry-run]
-y / --yes skip interactive [y/N] confirmation
--keep-data keep data/ (preserve pkg payloads for reinstall)
--dry-run print plan, change nothing
Exit codes:
0 success / dry-run completed
1 cancelled at prompt, safety refusal, or partial failure
2 invalid invocation (unknown flag) — also fired by the bonus
fix below for any unknown `xlings self <action>`
## Cross-platform self-deletion
- Linux/macOS: kernel decouples open file from dirent, so the
running xlings binary can be unlink'd in place. Process chdir's
to "/" (or $TMPDIR) first so it doesn't end up with a dangling
cwd inside the deleted tree.
- Windows: a running .exe can't be deleted. Strategy: move
xlings.exe to %TEMP%\xlings-pending-delete-<pid>.exe (same-volume
rename works on a running exe), schedule that temp copy for
delete-on-reboot. XLINGS_HOME is fully gone immediately; one
cleanup file lingers in %TEMP% until restart. (TODO: route the
actual MoveFileExW(MOVEFILE_DELAY_UNTIL_REBOOT) call through
xlings.platform — for now the temp file is harmless until either
reboot or manual cleanup.)
## Safety invariants
1. Refuse when XLINGS_HOME canonicalizes to root, /usr, /etc, /home,
a Windows system path, or exactly $HOME (without subdir suffix).
Catches mis-set XLINGS_HOME from nuking /.
2. Refuse when $XLINGS_HOME/.lock exists (another op in progress).
3. Always print the deletion summary before doing anything, even
with -y, so script logs capture what was removed.
4. Best-effort: a single rm failure logs a warning and continues;
final return code reflects total failures so the caller can
react.
## What's preserved (default)
- User shell rc files (~/.bashrc, ~/.zshrc, ~/.profile, fish config).
We DETECT and PRINT lines that source xlings's profile so the user
can manually clean them — never auto-edit (rc-file mutation is
fragile + risks corrupting non-xlings content).
- Project-local <project>/.xlings/ directories — user-owned.
- ~/.xmake — not xlings-owned.
## Bonus: unknown-action non-zero exit
`xlings self bogus-action` previously fell through to the help screen
and exited 0 — bad signal for automation. Now returns exit 2 with an
explicit "unknown 'self' action" error message. Real help requests
(`xlings self`, `xlings self -h`, `xlings self --help`) keep returning
0 as before.
## Files
- src/core/xself/uninstall.cppm (new — cmd_uninstall + helpers)
- src/core/xself.cppm (router + help + unknown-action fix)
- tests/e2e/self_uninstall_test.sh (new — 8 sub-scenarios)
- .github/workflows/xlings-ci-linux.yml (wire E2E-02b)
- docs/plans/2026-05-04-self-uninstall-design.md (design doc)
## Verified locally
Build: xmake build xlings — ok in 15s
Isolated XLINGS_HOME (separate from /home/speak/.xlings):
T1 --dry-run -y → exit 0, files unchanged ✓
T2 empty stdin (no confirm) → exit 1, files unchanged ✓
T3 bogus self action → exit 2 ✓ (regression guard)
T4 bogus uninstall flag → exit 2 ✓
T5 XLINGS_HOME=/ → exit 1, refused ✓
T6 XLINGS_HOME=$HOME → exit 1, refused ✓
T7 --keep-data -y → exit 0; data/ preserved,
bin/subos/config/.xlings.json
gone ✓
T8 full -y uninstall → exit 0; XLINGS_HOME gone
entirely ✓
System /home/speak/.xlings: SHA + pkg count unchanged across all
test runs (verified via baseline sha256 99e2660...).
E2E test (tests/e2e/self_uninstall_test.sh) passes locally end-to-end.
2 of 3 tasks
Sunrisepeak
added a commit
that referenced
this pull request
May 3, 2026
Bumps VERSION 0.4.13 → 0.4.14. Highlights since 0.4.13: * #259 — `load_project_config_` falls through to XLINGS_PROJECT_DIR env after a projectScope:false skip. Fixes "no version set for gcc-specs-config" in installs where the cwd traversal happens to hit a projectScope:false `.xlings.json` (e.g. xlings's own repo when E2E tests run from inside `tests/e2e/runtime/...`) before reaching the real project root. Concrete impact: gcc.lua's config hook spawning the gcc-specs-config script-type shim now resolves the project workspace correctly via env fallback. * #260 — CI bumps XIM_PKGINDEX_REF to xim-pkgindex main HEAD (19f4383), now including: - #110 / #111 namespace bare-name deps - #116 standalone xim:gcc-runtime (~25 MB, vs full xim:gcc ~1.1 GB) - #117 ninja/node/mdbook switched to xim:gcc-runtime - #118 gcc-runtime declares correct exports.runtime.libdirs End-to-end E2E-05 now exercises the full predicate-driven elfpatch + script-as-runtime-dep flow without sidestep workarounds. * #261 — `xlings self uninstall` is now a real command. Previously the dispatcher silently fell through to help and exited 0, even though user-facing hints (and the `xlings remove xim:xlings` single-version guard) explicitly routed users here. Implements: - `xlings self uninstall` (interactive [y/N]) - `-y` / `--yes` for automation - `--keep-data` to preserve `data/` for quick reinstall - `--dry-run` to print plan without changes Cross-platform self-deletion: Linux/macOS use the kernel's open-file-vs-dirent decoupling to unlink the running binary; Windows moves xlings.exe to %TEMP% and schedules delete-on- reboot for the temp copy (XLINGS_HOME is fully gone immediately). Safety invariants: refuses XLINGS_HOME=/, =$HOME, common system paths; refuses if `.lock` present; always prints summary even with `-y`. Bonus: `xlings self <unknown-action>` now exits 2 instead of silent 0. Migration: 0.4.13 → 0.4.14 is binary-compatible. self-update via `xself install` / quick_install handles the upgrade. Verified locally: 8/8 isolated-XLINGS_HOME tests pass; system /home/speak/.xlings sha256 + pkg count untouched across runs. CI three-platform green on PR #261.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the long-standing gap where
xlings remove xim:xlingsrefuses single-version self-removal and routes the user toself uninstall, but the command silently fell through to help and exited 0 — a footgun for automation.Semantics
xlings remove xim:xlings@VERxlings self uninstallCLI
-y/--yes[y/N]--keep-datadata/for quick reinstall (~12 GB pkg payloads stay)--dry-runExit codes: 0 success, 1 cancel/safety/partial, 2 unknown invocation (also catches
xlings self bogusnow — see bonus fix below).Cross-platform self-deletion
chdir("/")first to avoid dangling cwd.xlings.exe→%TEMP%\xlings-pending-delete-<pid>.exe(same-volume rename works on running exe), schedule that for delete-on-reboot. XLINGS_HOME is fully gone immediately; only one cleanup file in %TEMP% until restart.Safety
XLINGS_HOMEis/,/usr,/home, exactly$HOME, common Windows system paths, or non-absolute / single-component path. Defense against mis-set env.$XLINGS_HOME/.lockexists (concurrent op).-y(script logs capture what's removed).What's preserved (default)
~/.bashrcetc.) — DETECT lines sourcing the profile and PRINT them as advisory; never auto-edit (too risky on shared rc files).<project>/.xlings/— user-owned.~/.xmake/— not xlings-owned.Bonus fix: unknown-action exit code
Previously
xlings self bogus-actionfell through to help screen and exited 0. Now exits 2 with explicit "unknown 'self' action" message. Genuine help requests (xlings self/-h/--help) keep returning 0.Verified locally — 8/8 PASS
--dry-run -yXLINGS_HOME=/XLINGS_HOME=$HOME--keep-data -y-ySystem
/home/speak/.xlingsSHA256 + pkg count untouched across all runs (independence verified).Files
src/core/xself/uninstall.cppm— new module (cmd_uninstall, helpers)src/core/xself.cppm— dispatch + help + unknown-action fixtests/e2e/self_uninstall_test.sh— 8 sub-tests.github/workflows/xlings-ci-linux.yml— wire asE2E-02bdocs/plans/2026-05-04-self-uninstall-design.md— full designTest plan
xmake build xlings)E2E-02bexercises the core code paths; cross-platform delete-on-reboot for Windows is a TODO (see code comment) but doesn't block Linux/macOS uninstall correctness.