From 31711429401e2300b6ea5c40e590271900bccb2a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 14:22:17 +0000 Subject: [PATCH 1/2] fix(env): expose Devbox profile share dir via XDG_DATA_DIRS for completions Package-provided shell completions were never active inside a Devbox shell (e.g. `kubectl ` 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) Claude-Session: https://claude.ai/code/session_01EuAos6xjPuVdUWNEVvCYh1 --- internal/devbox/devbox.go | 12 ++++++++++++ testscripts/run/xdg_data_dirs.test.txt | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 testscripts/run/xdg_data_dirs.test.txt diff --git a/internal/devbox/devbox.go b/internal/devbox/devbox.go index 4c3f82421ce..45edd6f8e2f 100644 --- a/internal/devbox/devbox.go +++ b/internal/devbox/devbox.go @@ -820,6 +820,18 @@ func (d *Devbox) computeEnv( slog.Debug("computed environment PATH", "path", env["PATH"]) + // Expose the Devbox profile's share directory through XDG_DATA_DIRS so that + // data files installed by packages are discoverable inside the Devbox + // environment. Most notably this includes shell completions (which Nix + // packages install under share/bash-completion/completions), but also man + // pages, icons, and other XDG data. Tools such as bash-completion look these + // up via XDG_DATA_DIRS, so without the profile's share directory the + // completions shipped by packages like kubectl are never loaded. This is + // done even in --pure mode so completions keep working there too. + // See https://github.com/jetify-com/devbox/issues/2776 + profileShareDir := filepath.Join(d.projectDir, nix.ProfilePath, "share") + env["XDG_DATA_DIRS"] = envpath.JoinPathLists(profileShareDir, env["XDG_DATA_DIRS"]) + if !envOpts.Pure { // preserve the original XDG_DATA_DIRS by prepending to it env["XDG_DATA_DIRS"] = envpath.JoinPathLists(env["XDG_DATA_DIRS"], os.Getenv("XDG_DATA_DIRS")) diff --git a/testscripts/run/xdg_data_dirs.test.txt b/testscripts/run/xdg_data_dirs.test.txt new file mode 100644 index 00000000000..9a4f2023535 --- /dev/null +++ b/testscripts/run/xdg_data_dirs.test.txt @@ -0,0 +1,13 @@ +# The Devbox profile's share directory must be exposed through XDG_DATA_DIRS so +# that data files installed by packages are discoverable inside the Devbox +# environment. Most importantly this lets tools like bash-completion find the +# shell completions that packages install under share/bash-completion/completions. +# https://github.com/jetify-com/devbox/issues/2776 + +exec devbox run echo '$XDG_DATA_DIRS' +stdout '\.devbox/nix/profile/default/share' + +-- devbox.json -- +{ + "packages": [] +} From 490d26a03d5961c76d9bdd17a05454697e31d64e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 14:26:09 +0000 Subject: [PATCH 2/2] test(run): assert profile share dir is on XDG_DATA_DIRS in --pure mode 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) Claude-Session: https://claude.ai/code/session_01EuAos6xjPuVdUWNEVvCYh1 --- testscripts/run/xdg_data_dirs.test.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testscripts/run/xdg_data_dirs.test.txt b/testscripts/run/xdg_data_dirs.test.txt index 9a4f2023535..765ad1648bc 100644 --- a/testscripts/run/xdg_data_dirs.test.txt +++ b/testscripts/run/xdg_data_dirs.test.txt @@ -7,6 +7,11 @@ exec devbox run echo '$XDG_DATA_DIRS' stdout '\.devbox/nix/profile/default/share' +# The profile's share directory must also be exposed in --pure mode, where the +# host's XDG_DATA_DIRS is not inherited, so completions keep working there too. +exec devbox run --pure echo '$XDG_DATA_DIRS' +stdout '\.devbox/nix/profile/default/share' + -- devbox.json -- { "packages": []