fix: reduce yq forks per reference from 6 to 1, silence git thread errors

parse_reference was calling yq 5-7 times per reference. With 8 refs
that's ~48 fork+exec calls in rapid succession, saturating IONOS's
ulimit -u and causing intermittent empty 'into' fields — libraries then
installed to the wrong .arty/libs/ location instead of their configured
path.

Collapse all field reads into a single yq expression per reference.

Also add 2>/dev/null to git fetch/pull so the "getaddrinfo() thread
failed to start" message (another ulimit hit, in git's DNS resolver)
doesn't spam the output — the warn message still fires on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 22:59:40 +02:00
parent 6d692cef57
commit 90f7b58a53
+15 -34
View File
@@ -281,39 +281,20 @@ parse_reference() {
local config_file="$1"
local ref_index="$2"
# Check if reference is a string or object
local ref_type=$(yq eval ".references[$ref_index] | type" "$config_file" 2>/dev/null)
if [[ "$ref_type" == "!!str" ]]; then
# Simple string format: just the URL
local url=$(yq eval ".references[$ref_index]" "$config_file" 2>/dev/null)
echo "$url||||"
else
# Object format with url, into, ref, env fields
local url=$(yq eval ".references[$ref_index].url" "$config_file" 2>/dev/null)
local into=$(yq eval ".references[$ref_index].into" "$config_file" 2>/dev/null)
local ref=$(yq eval ".references[$ref_index].ref" "$config_file" 2>/dev/null)
# Check if env is an array or string
local env_type=$(yq eval ".references[$ref_index].env | type" "$config_file" 2>/dev/null)
local env=""
if [[ "$env_type" == "!!seq" ]]; then
# Array format - convert to comma-separated string
env=$(yq eval ".references[$ref_index].env | join(\",\")" "$config_file" 2>/dev/null)
# Single yq call for all fields — multiple calls per reference were flooding
# the process table on hosts with low ulimit -u (e.g. IONOS shared hosting),
# causing intermittent empty 'into' values and wrong install locations.
yq eval "
.references[$ref_index] as \$r |
if (\$r | type) == \"!!str\" then
\$r + \"|||\"
else
# Single value or null
env=$(yq eval ".references[$ref_index].env" "$config_file" 2>/dev/null)
fi
# Replace "null" with empty string
[[ "$url" == "null" ]] && url=""
[[ "$into" == "null" ]] && into=""
[[ "$ref" == "null" ]] && ref=""
[[ "$env" == "null" ]] && env=""
echo "$url|$into|$ref|$env"
fi
((\$r.url // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
((\$r.into // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
((\$r.ref // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
(\$r.env | if . == null then \"\" elif type == \"!!seq\" then join(\",\") else (. | if . == \"null\" then \"\" else . end) end)
end
" "$config_file" 2>/dev/null
}
# Check if current environment matches the filter
@@ -463,11 +444,11 @@ install_lib() {
# Try to update
if [[ -n "$git_ref" ]]; then
(cd "$lib_dir" && git fetch -q && git checkout -q "$git_ref" && git pull -q) || {
(cd "$lib_dir" && git fetch -q 2>/dev/null && git checkout -q "$git_ref" && git pull -q 2>/dev/null) || {
log_warn "Failed to update library (continuing with existing version)"
}
else
(cd "$lib_dir" && git fetch -q && git pull -q) || {
(cd "$lib_dir" && git fetch -q 2>/dev/null && git pull -q 2>/dev/null) || {
log_warn "Failed to update library (continuing with existing version)"
}
fi