feat: migrate to XDG/FHS install locations#23
Open
ukanga wants to merge 3 commits into
Open
Conversation
50b8b72 to
db2ba0f
Compare
Move global config to $XDG_CONFIG_HOME/wt/config.toml (default ~/.config/wt/) and session state to $XDG_STATE_HOME/wt/sessions.json (default ~/.local/state/wt/). XDG helpers use hand-rolled env-var logic rather than dirs::config_dir() / dirs::state_dir(), which return Apple paths on macOS. Relative values for XDG_CONFIG_HOME and XDG_STATE_HOME are rejected per the XDG Base Directory spec and silently fall back to the defaults. Legacy ~/.wt/ paths are still read as a fallback with a one-time stderr notice, so existing users keep working without re-running the installer. Directory creation only happens on write; the read path resolves the path without touching the filesystem. Env-mutating tests are serialised through a crate-level Mutex to prevent races under cargo's parallel test runner.
…m flag Install to ~/.local/bin/wt (on PATH by default on modern Linux) instead of ~/.wt/wt behind a shell alias. Drop alias-writing entirely. Add a --system flag to install to /usr/local/bin/wt with sudo. Directory creation uses the same privilege path as the binary copy, so --system never hits a permissions error before reaching sudo. When re-run on a machine with the old layout the installer: - removes the comment+alias block it previously wrote from shell rc files - deletes ~/.wt/wt - moves ~/.wt/config.toml and ~/.wt/sessions.json to their XDG locations - removes ~/.wt/ if it is then empty Alias removal uses awk (portable across GNU/Linux and BSD/macOS) and only deletes the exact two-line block the old installer wrote; user-defined aliases are never touched. The helper is a top-level function, not nested inside migrate_legacy. The temp file used for release downloads is guarded by an EXIT trap so it is always cleaned up even if curl or the install step fails. XDG_CONFIG_HOME and XDG_STATE_HOME are validated for absolute paths before use, matching the Rust helpers; relative or empty values fall back to $HOME/.config and $HOME/.local/state. If the install directory is not on PATH (common on macOS) the installer prints a single instruction line and does not modify any shell rc file.
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 #21.
Summary
~/.wt/wt(shell alias) to~/.local/bin/wt(onPATH)~/.wt/config.tomlto$XDG_CONFIG_HOME/wt/config.toml(default~/.config/wt/)~/.wt/sessions.jsonto$XDG_STATE_HOME/wt/sessions.json(default~/.local/state/wt/)~/Library/Application Support/Changes
src/config.rs/src/session.rs: Hand-rolledxdg_config_home()/xdg_state_home()helpers (avoidsdirs::config_dir()/dirs::state_dir()which return Apple paths on macOS). Legacy~/.wt/paths are read as a fallback with a one-time stderr notice; writes always go to the new locations.install.sh: Installs to~/.local/bin/wtby default.--systemflag installs to/usr/local/bin/wt(withsudo). Alias-writing block removed entirely. Re-running the installer migrates legacy files, removes stale shell aliases from rc files, and cleans up~/.wt/if empty. Prints a one-line PATH instruction if the install dir is not on$PATH(macOS).README.md: Updated Installation and Configuration sections.Test plan
~/.wt/): binary at~/.local/bin/wt, nothing written under~/.wt/./install.sh --systeminstalls to/usr/local/bin/wt~/.config/wt/and~/.local/state/wt/~/.wt/removed, aliases stripped from rc files,which wtresolves to new pathXDG_CONFIG_HOME/XDG_STATE_HOMEenv vars honouredwtreads from~/.wt/with deprecation noticecargo testpasses (60 unit + integration tests including new XDG and legacy-fallback tests)