mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
fix(hermes): heal broken managed Node tree instead of PATH fallback
When a Hermes-managed node/npm/npx shim exists but fails --version, redownload the pinned nodejs.org bundle under HERMES_HOME/node and retry. Do not fall back to system npm on PATH when a managed tree is present. POSIX heal probes node, npm, and npx (npm can break while node still runs).
This commit is contained in:
parent
3c5bcd3eee
commit
65be0061e0
4 changed files with 260 additions and 14 deletions
|
|
@ -229,6 +229,49 @@ _nb_install_bundled_node() {
|
|||
return 0
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Heal a broken Hermes-managed Node tree (partial upgrade / missing lib/)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_nb_managed_tool_broken() {
|
||||
local tool="$1"
|
||||
local probe
|
||||
for probe in \
|
||||
"$HERMES_HOME/node/bin/$tool" \
|
||||
"$HERMES_HOME/node/${tool}.exe" \
|
||||
"$HERMES_HOME/node/$tool"; do
|
||||
if [ -x "$probe" ] || [ -f "$probe" ]; then
|
||||
if ! "$probe" --version >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
_nb_managed_node_needs_heal() {
|
||||
local tool
|
||||
for tool in node npm npx; do
|
||||
if _nb_managed_tool_broken "$tool"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Redownload the pinned nodejs.org tarball when a managed tree exists but
|
||||
# node/npm/npx fail a --version probe. No-op when the tree is healthy or
|
||||
# absent. Used by hermes_constants.find_hermes_node_executable() and safe
|
||||
# to call from install reruns.
|
||||
heal_managed_node() {
|
||||
[ -d "$HERMES_HOME/node" ] || return 1
|
||||
if ! _nb_managed_node_needs_heal; then
|
||||
return 0
|
||||
fi
|
||||
_nb_log "Hermes-managed Node is broken — redownloading to $HERMES_HOME/node/..."
|
||||
_nb_install_bundled_node
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public entry point
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue