Skip to content

fix(installer): resolve the gateway config dir like the CLI does - #4063

Open
fede-kamel wants to merge 1 commit into
NVIDIA:mainfrom
fede-kamel:fix/4042-installer-xdg-config-home
Open

fede-kamel wants to merge 1 commit into
NVIDIA:mainfrom
fede-kamel:fix/4042-installer-xdg-config-home

Conversation

@fede-kamel

Copy link
Copy Markdown
Contributor

Summary

install.sh hardcoded $TARGET_HOME/.config/openshell in two places while the
CLI keeps gateway entries and client certificates under
$XDG_CONFIG_HOME/openshell whenever that variable is set:

  • wait_for_local_gateway_listener, which reads the mTLS client bundle that the
    gateway registration writes.
  • remove_local_gateway_registration, which clears a stale openshell entry
    before re-adding it.

With XDG_CONFIG_HOME pointing anywhere other than ~/.config, the installer
and the CLI looked in different directories: the readiness check waited out its
timeout on certificates that were never going to appear there, and the cleanup
left the real stale entry untouched.

Related Issue

Fixes #4042

Changes

  • Add target_openshell_config_dir, which resolves the directory through
    as_target_user so the answer comes from the same environment the CLI is
    invoked in. This covers both branches without restating their logic: the
    same-user branch inherits the caller's XDG_CONFIG_HOME, while the sudo and
    runuser branches reset the environment and fall back to the target user's
    home.
  • Use it for the readiness check and the registration cleanup.

remove_snap_gateway_registration is deliberately untouched: the snap confines
its own config root under ~/snap/openshell/common/.config, which is not
XDG_CONFIG_HOME.

Testing

Added three assertions to tasks/scripts/test-install-sh.sh, which sources
install.sh and exercises the function directly. Full suite passes:

$ bash tasks/scripts/test-install-sh.sh
install.sh focused tests passed

They are a real guard, not a vacuous pass — reverting only the helper to the old
hardcoded path fails the suite:

FAIL: XDG_CONFIG_HOME is honored: expected /tmp/tmp.XXXX/xdg-config/openshell,
      got /tmp/tmp.XXXX/target-home/.config/openshell

Resolution probed against the CLI's own rule
(openshell_core::paths::xdg_config_dir joined with openshell), running the
real as_target_user:

XDG_CONFIG_HOME CLI resolves before after
unset $HOME/.config/openshell match match
/home/u/cfg /home/u/cfg/openshell mismatch match
set but empty openshell (relative) mismatch $HOME/.config/openshell

A divergence worth a separate look

The empty case is the one place this does not match the CLI byte for byte. The
installer follows the XDG base directory specification, which says an empty
value is treated as unset. xdg_config_dir instead takes env::var's Ok("")
as set and joins onto it, so it yields the relative path openshell,
resolved against the process working directory. No installer path can usefully
match that, and it looks like a bug on the CLI side rather than something to
mirror here. Happy to file it separately if you agree.

install.sh hardcoded $TARGET_HOME/.config/openshell in two places: the
readiness check, which reads the client certificates it expects the
gateway registration to have written, and the cleanup that removes a
stale openshell entry before re-adding it. The CLI instead keeps both
under $XDG_CONFIG_HOME/openshell whenever that variable is set, so with
the variable pointing anywhere other than ~/.config the installer and
the CLI looked in different directories: the readiness check waited for
certificates that were never going to appear there, and the cleanup left
the real stale entry in place.

Resolve the directory through as_target_user instead, which answers from
the same environment the CLI is invoked in. That covers both branches
without duplicating their logic: the same-user branch inherits the
caller's XDG_CONFIG_HOME, while the sudo and runuser branches reset the
environment and fall back to the target user's home.

An empty XDG_CONFIG_HOME falls back to $HOME/.config, following the XDG
base directory specification. The CLI diverges here: xdg_config_dir
treats a set-but-empty value as set and joins onto it, yielding the
relative path "openshell", which no installer path can usefully match.
Worth fixing separately in the CLI.

Signed-off-by: fede-kamel <fkamelhar@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
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.

bug: install.sh ignores XDG_CONFIG_HOME for the local gateway config

1 participant