Skip to content

refactor: migrate installation to XDG Base Directory Specification#1569

Merged
harehare merged 1 commit intoharehare:mainfrom
minhdqdev:feature/xdg-install-paths
Apr 10, 2026
Merged

refactor: migrate installation to XDG Base Directory Specification#1569
harehare merged 1 commit intoharehare:mainfrom
minhdqdev:feature/xdg-install-paths

Conversation

@minhdqdev
Copy link
Copy Markdown

@minhdqdev minhdqdev commented Apr 10, 2026

Problem

The current mq installer uses ~/.mq/bin/ for binary installation, which doesn't follow the standard ~/.local/bin/ path used by most tools.

Solution

Migrate to ~/.local/bin/ following FHS (Filesystem Hierarchy Standard):

  • Binary installation: ~/.mq/bin/~/.local/bin/
  • Supports environment variable overrides: MQ_HOME, XDG_DATA_HOME

Changes

  1. scripts/install.sh — Updated MQ_BIN_DIR to use ~/.local/bin/
  2. crates/mq-run/src/cli.rs — Changed path from ~/.mq/bin to ~/.local/bin
  3. README.md — Updated installation path documentation

Benefits

  • ✅ Standards compliant (FHS)
  • ✅ Aligns with industry tools (pipx, jq, gh, cargo)
  • ✅ Cleaner PATH management
  • ✅ Minimal code changes

@minhdqdev minhdqdev marked this pull request as draft April 10, 2026 03:52
This change aligns mq's installation strategy with industry standards and the
Filesystem Hierarchy Standard (FHS), improving standards compliance,
performance, and organization.

## What Changed

- Binary installation path: ~/.mq/bin/ -> ~/.local/bin/
- Plugin directory: ~/.mq/bin/ -> ~/.local/share/mq/plugins/
- New config directory support: ~/.config/mq/ (for future use)

## Key Features

1. **XDG Base Directory Compliance**
   - Respects XDG_DATA_HOME, XDG_CONFIG_HOME environment variables
   - Uses standard ~/.local/bin for user binaries
   - Uses ~/.local/share/mq/plugins/ for user plugins

2. **Environment Variable Support**
   - MQ_HOME: Custom base directory for plugins
   - XDG_DATA_HOME: Custom data directory
   - XDG_CONFIG_HOME: Custom config directory

3. **Full Backward Compatibility**
   - Plugin discovery searches in priority order:
     1. $MQ_HOME/plugins
     2. $XDG_DATA_HOME/mq/plugins
     3. ~/.local/bin/
     4. ~/.mq/bin/ (legacy fallback)
     5. $PATH directories
   - Existing ~/.mq/bin installations continue to work

## Standards Alignment

- FHS: ~/.local/bin is the standard for user-installed binaries
- XDG Base Directory Spec: Proper separation of binaries, data, and config
- Industry practice: Aligns with pipx, cargo, jq, gh, and other tools

## Benefits

- Reduced PATH clutter: ~/.local/bin already typically in PATH
- Faster shell startup: Fewer PATH entries to traverse
- Better organization: Separation of binaries, data, and config
- Standards compliance: Follows FHS and XDG specifications

## Migration

Existing users can:
- Re-run the installer to update paths
- Or manually migrate (see MIGRATION_GUIDE.md)
- Legacy ~/.mq/bin path still works as fallback

Fixes: Standards compliance issues (FHS, XDG)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@minhdqdev minhdqdev force-pushed the feature/xdg-install-paths branch from 08a9a8e to 4693eee Compare April 10, 2026 03:54
@minhdqdev minhdqdev marked this pull request as ready for review April 10, 2026 03:58
@minhdqdev
Copy link
Copy Markdown
Author

Hi @harehare, love your tool. I have a small refactor that can improve it.

@harehare harehare self-requested a review April 10, 2026 11:08
@harehare
Copy link
Copy Markdown
Owner

Thank you for the contribution!

Agreed, ~/.local/bin/ is a much better default.
I'm also planning to align the other subcommands to use ~/.local/bin/ as well for consistency.

@harehare harehare merged commit b30c06d into harehare:main Apr 10, 2026
4 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.

2 participants