fix(env): expose Devbox profile share dir via XDG_DATA_DIRS so package completions work - #2926
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
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.
| 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
|
@claude please review this PR for correctness, and flag anything that would block merging. |
|
Claude finished @mikeland73's task in 2m 36s —— View job Review of PR #2926
SummaryI reviewed the diff ( Correctness
Test coverage
Minor, non-blocking notes
Overall: the implementation is correct, consistent with existing patterns, and the test coverage now includes both pure and non-pure modes. I did not run |
|
@mikeland73 Reviewed for correctness and merge-readiness. Summary: the change is correct and I found no blocking bugs. The only thing stopping a merge is that the PR is currently a draft. Correctness ✅The mechanism is right. Things I verified specifically:
Merge blockers
Two non-blocking notes for your call
Net: correct and ready to go once it's out of draft. Let me know if you'd like me to (a) mark it ready and/or (b) add the empty- Generated by Claude Code |
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