fix(env): expose Devbox profile share dir via XDG_DATA_DIRS so package completions work#2926
Open
mikeland73 wants to merge 2 commits into
Open
fix(env): expose Devbox profile share dir via XDG_DATA_DIRS so package completions work#2926mikeland73 wants to merge 2 commits into
mikeland73 wants to merge 2 commits into
Conversation
…etions Package-provided shell completions were never active inside a Devbox shell (e.g. `kubectl <TAB>` did nothing on a fresh Ubuntu + bash setup). Nix packages install their bash completions under `share/bash-completion/completions/`, and bash-completion's dynamic loader discovers them by scanning the `bash-completion/completions` subdirectory of every entry in `XDG_DATA_DIRS`. Devbox only preserved the host's original `XDG_DATA_DIRS` and never added the Devbox profile's own `share` directory (`.devbox/nix/profile/default/share`), so the completions (and other XDG data like man pages and icons) shipped by installed packages were invisible. Prepend the profile's `share` directory to `XDG_DATA_DIRS` when computing the environment. This is done even in `--pure` mode so completions keep working there too, and it mirrors how nix-env / home-manager expose the same data. Fixes #2776 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EuAos6xjPuVdUWNEVvCYh1
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes missing package-provided shell completions (and other XDG data like man pages/icons) inside Devbox environments by ensuring the project profile’s share/ directory is discoverable via XDG_DATA_DIRS.
Changes:
- Prepend
.devbox/nix/profile/default/sharetoXDG_DATA_DIRSwhen computing the Devbox environment (including--pure). - Add a run testscript that asserts
XDG_DATA_DIRSincludes the profileshare/directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/devbox/devbox.go | Prepends the Devbox profile share dir to XDG_DATA_DIRS during environment computation. |
| testscripts/run/xdg_data_dirs.test.txt | Adds coverage to ensure XDG_DATA_DIRS exposes the profile share directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+9
| exec devbox run echo '$XDG_DATA_DIRS' | ||
| stdout '\.devbox/nix/profile/default/share' | ||
|
|
…e too The fix sets XDG_DATA_DIRS for both regular and --pure environments; add a --pure assertion so the pure-shell path is guarded against regressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EuAos6xjPuVdUWNEVvCYh1
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.
Summary
Fixes #2776.
Package-provided shell completions were never active inside a Devbox shell. For
example, on a fresh Ubuntu + bash setup,
kubectl <TAB>does nothing even thoughthe
kubectlNix package ships a completion script.Root cause
Nix packages install their bash completions under
share/bash-completion/completions/<cmd>, andbash-completion's dynamic loaderdiscovers them by scanning the
bash-completion/completionssubdirectory ofevery entry in
XDG_DATA_DIRSat completion time.When computing the environment (
internal/devbox/devbox.go), Devbox onlypreserved the host's original
XDG_DATA_DIRS:It never added the Devbox profile's own
sharedirectory(
.devbox/nix/profile/default/share), which is where all of a project'sinstalled packages aggregate their data files. As a result the completions — and
other XDG data such as man pages and icons — shipped by those packages were
invisible to the shell.
Fix
Prepend the profile's
sharedirectory toXDG_DATA_DIRSwhile computing theenvironment:
--pureenvironments, so completions keep workingin pure shells too.
envpath.JoinPathListscleans, dedupes, and drops empty/relative segments, sothis is a no-op if the entry is already present and it never introduces a
duplicate or an unsafe relative path.
nix-env/ home-manager expose the same data viaXDG_DATA_DIRS.How was it tested?
go build ./...andgo vet ./internal/devbox/— clean.testscripts/run/xdg_data_dirs.test.txt, which asserts thatdevbox run echo '$XDG_DATA_DIRS'includes.devbox/nix/profile/default/share.Manual verification of the underlying mechanism: with the profile's
sharedirectory on
XDG_DATA_DIRS,bash-completion's__load_completionfindsshare/bash-completion/completions/kubectlin the Devbox profile and activateskubectl <TAB>completion; the change is additive and does not alter any otherenvironment variable.
/cc @gberche-orange (issue reporter) — thanks for the clear report and the
upstream package links.
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EuAos6xjPuVdUWNEVvCYh1
Generated by Claude Code