Skip to content

Fix GitNexus not working with non-standard shell after extension updates + 2#10

Merged
tintinweb merged 6 commits into
tintinweb:masterfrom
y-almannaee:main
May 2, 2026
Merged

Fix GitNexus not working with non-standard shell after extension updates + 2#10
tintinweb merged 6 commits into
tintinweb:masterfrom
y-almannaee:main

Conversation

@y-almannaee
Copy link
Copy Markdown
Contributor

@y-almannaee y-almannaee commented Apr 28, 2026

This pull request fixes a bug where gitnexus commands would fail after the Pi coding agent updated pi-gitnexus, along with two small reliability improvements. The main issue happened because the extension was replacing the agent's entire PATH with the login shell's PATH, which lost directories like the one containing Node.js and nvm (where gitnexus was installed).

Changes:

  • Fixed erroneous error where it said gitnexus was not in PATH; the extension was not properly reading PATH entries (like the nvm directory) while looking for the gitnexus binary
  • Fixed swallowing errors on startup
  • Prevent crashes on error responses, added a safety check so the extension doesn't crash when it receives an error result from a tool (in auto-augment)

resolveShellPath() unconditionally overwrote process.env.PATH with the
login shell\u2019s PATH (from dash), silently dropping the agent\u2019s existing
entries such as ~/.local/share/nvm/v24.15.0/bin.  Since the login shell
PATH often lacks nvm/fnm/volta directories, child processes could no
longer find the gitnexus binary (ENOENT).

Add mergePaths() to preserve the agent\u2019s PATH entries and append any
shell-only directories at the end, so both sources are represented.
Also update the spawnEnv JSDoc to describe the merge behavior.
onSession() is fire-and-forget via void onSession(ctx), discarding the
Promise.  If resolveShellPath() or probeGitNexusBinary() rejects, the
extension enters a partially-initialized state (binaryAvailable stays
stale, spawnEnv stays stale) with zero user notification.

Add a .catch() handler that surfaces the error message via
ctx.ui.notify().
event.content.map() is called without checking if event.content exists.
Error tool results can have undefined content, causing a TypeError crash
in the async hook that disables all auto-augment for the session.

Add a guard at the top of the handler to return early when content is
missing or malformed.
Comment thread src/index.ts Outdated
Comment thread src/index.ts
/bin/sh does not exist on Windows and on macOS it will not source
.zshrc/.zprofile where Homebrew, nvm, volta etc. set their PATH
entries.  Use $SHELL on macOS/Linux and skip entirely on Windows
(where the agent\u2019s PATH is already correct).

mergePaths() now uses the platform-appropriate PATH separator (; on
Windows, : on macOS/Linux) instead of the hard-coded colon.
resolveShellPath() had no timeout, so a slow or broken login startup
file could stall session initialization indefinitely.  Add a 3-second
deadline that kills the probe and falls back to the agent\u2019s existing
PATH.

Use node:path delimiter instead of hard-coding ;/:, and make
mergePaths filter empty entries and deduplicate case-insensitively on
Windows.

Correct the JSDoc to reference login startup files (.zprofile,
.bash_profile, .profile) rather than interactive rc files (.zshrc,
.bashrc), which -lc does not source.
@y-almannaee y-almannaee requested a review from tintinweb May 2, 2026 07:51
@tintinweb tintinweb merged commit 90c4652 into tintinweb:master May 2, 2026
1 check passed
@y-almannaee y-almannaee deleted the main branch May 3, 2026 08:26
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.

2 participants