feat: detect self-reported PATH hints to fix command-not-found after … - #59
Open
KeymelGaston wants to merge 1 commit into
Open
feat: detect self-reported PATH hints to fix command-not-found after …#59KeymelGaston wants to merge 1 commit into
KeymelGaston wants to merge 1 commit into
Conversation
…install Some install scripts (e.g. openfang's curl | sh installer) install a binary, append a PATH export line to the shell rc file, and print a hint like 'export PATH=/some/dir:$PATH' instead of updating the current shell. Since all commands in a method run inside a single script, that rc-file change never takes effect mid-script, causing the next command to fail with 'command not found' even though installation succeeded (see #145). This adds a generic handler that detects that self-reported hint in the output and applies it to the process PATH before retrying, following the same pattern already used for known deps via PathAugment, but generalized to any install script that prints this common convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some install scripts (e.g. openfang's curl | sh installer) install a binary, append a PATH export line to the shell rc file, and print a hint like export PATH=/some/dir:$PATH instead of updating the current shell.
Since all commands in a method run inside a single generated script (see buildAndRun in installcommand.go), that rc-file change never takes effect mid-script — so the very next command fails with command not found even though installation succeeded. This is exactly what's reported in #145.
Fix
Adds a generic handler, following the same pattern already used for pip/python swapping and the PathAugment table for known deps (Bun, PHP, Homebrew, etc.):
Instead of hardcoding a per-repo special case, this parses the PATH hint the install script already prints, and applies it to the process PATH before retrying — so it generalizes to any install script that follows this common convention, not just openfang.
Testing
Reproduced the exact scenario from #145 (installing RightNow-AI/openfang on Ubuntu 24.04 / Linux Mint) with a locally built binary.
Before the fix — fails right after a successful install:
openfang Added to PATH via /home/user/.bashrc
...
/tmp/ipm-xxxxx.sh: line 4: openfang: command not found
After the fix — the hint is detected, PATH is updated, and the install completes end-to-end (init + daemon start both succeed):
/tmp/ipm-xxxxx.sh: line 4: openfang: command not found
ℹ Detected a PATH hint in the output (/home/user/.openfang/bin). Retrying with updated PATH...
...
✔ OpenFang initialized (quick mode)
...
OpenFang API server listening on http://127.0.0.1:4200
Note on scope
This ended up being more of a generalization than a narrow fix — instead of special-casing openfang, it extends the existing handler pattern to any install script that self-reports a PATH hint. Happy to narrow the approach if you'd prefer something more scoped — open to feedback before/after merge.