Skip to content

feat: detect self-reported PATH hints to fix command-not-found after … - #59

Open
KeymelGaston wants to merge 1 commit into
HexmosTech:mainfrom
KeymelGaston:fix/path-hint-detection
Open

feat: detect self-reported PATH hints to fix command-not-found after …#59
KeymelGaston wants to merge 1 commit into
HexmosTech:mainfrom
KeymelGaston:fix/path-hint-detection

Conversation

@KeymelGaston

Copy link
Copy Markdown

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.):

if !pathHintApplied && strings.Contains(strings.ToLower(output), "command not found") {
    pathHintRegex := regexp.MustCompile(`export PATH=([^\s:"']+)`)
    if matches := pathHintRegex.FindStringSubmatch(output); len(matches) > 1 {
        hintedDir := matches[1]
        // ... prepend hintedDir to the process PATH and retry
    }
}

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.

…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.
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.

1 participant