Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/devbox/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
18 changes: 18 additions & 0 deletions testscripts/run/xdg_data_dirs.test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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'

# 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": []
}
Loading