From 22a3fdc99dc5c33282bf7919ea91544ae1c5728a Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Thu, 15 Oct 2026 19:20:59 +0200 Subject: [PATCH] Keep VM release lookups working without system.func #138 made _forge_release_json call ensure_dependencies, which VM scripts never load: every vm_release_asset lookup (ZimaOS, k3s, Pimox HAOS) failed with 'command not found' (ProxmoxVE #17939). Use it when it is there, otherwise only require jq. --- lib/forge.func | 8 +++++++- tests/forge-release-json.sh | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/forge.func b/lib/forge.func index 601e284..d53c9c6 100644 --- a/lib/forge.func +++ b/lib/forge.func @@ -1482,7 +1482,13 @@ _forge_release_json() { local tag_prefix="${4:-}" out="${5:?outfile}" # The install path arrives here without check_for_release; a Proxmox host has no jq. - ensure_dependencies jq || return 100 + # VM scripts load this file without system.func and bring jq themselves. + if declare -F ensure_dependencies >/dev/null; then + ensure_dependencies jq || return 100 + elif ! command -v jq >/dev/null 2>&1; then + msg_error "jq is required to read ${repo}'s releases" + return 100 + fi local base repo_path list one base="$(_forge_descriptor "$forge" base)" diff --git a/tests/forge-release-json.sh b/tests/forge-release-json.sh index e58aed1..37de867 100644 --- a/tests/forge-release-json.sh +++ b/tests/forge-release-json.sh @@ -74,6 +74,22 @@ MOCK_DEPS_RC=1 run expect "a missing jq stops the lookup" 100 "$?" expect "nothing is fetched without jq" 0 "$(grep -c curl "$CALLS")" +# VM scripts load forge.func without system.func. +( + unset -f ensure_dependencies + MOCK_BODY='[{"tag_name":"v1.0.0","draft":false,"prerelease":false}]' run +) +expect "without system.func the lookup uses the jq that is there" 0 "$?" +expect "without system.func the release resolves" v1.0.0 "$(jq -r .tag_name "$OUT")" + +( + unset -f ensure_dependencies + PATH="$TEST_DIR/no-bin" + run +) +expect "without system.func a missing jq stops the lookup" 100 "$?" +expect "without system.func nothing is fetched without jq" 0 "$(grep -c curl "$CALLS")" + MOCK_BODY='[{"tag_name":"v1.0.0","draft":false,"prerelease":false},{"tag_name":"v2.0.0-rc.1","draft":false,"prerelease":true}]' run expect "the release list still resolves" 0 "$?" expect "the stable release wins" v1.0.0 "$(jq -r .tag_name "$OUT")"