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:
+15
-34
@@ -281,39 +281,20 @@ parse_reference() {
|
|||||||
local config_file="$1"
|
local config_file="$1"
|
||||||
local ref_index="$2"
|
local ref_index="$2"
|
||||||
|
|
||||||
# Check if reference is a string or object
|
# Single yq call for all fields — multiple calls per reference were flooding
|
||||||
local ref_type=$(yq eval ".references[$ref_index] | type" "$config_file" 2>/dev/null)
|
# the process table on hosts with low ulimit -u (e.g. IONOS shared hosting),
|
||||||
|
# causing intermittent empty 'into' values and wrong install locations.
|
||||||
if [[ "$ref_type" == "!!str" ]]; then
|
yq eval "
|
||||||
# Simple string format: just the URL
|
.references[$ref_index] as \$r |
|
||||||
local url=$(yq eval ".references[$ref_index]" "$config_file" 2>/dev/null)
|
if (\$r | type) == \"!!str\" then
|
||||||
echo "$url||||"
|
\$r + \"|||\"
|
||||||
else
|
else
|
||||||
# Object format with url, into, ref, env fields
|
((\$r.url // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
|
||||||
local url=$(yq eval ".references[$ref_index].url" "$config_file" 2>/dev/null)
|
((\$r.into // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
|
||||||
local into=$(yq eval ".references[$ref_index].into" "$config_file" 2>/dev/null)
|
((\$r.ref // \"\") | if . == \"null\" then \"\" else . end) + \"|\" +
|
||||||
local ref=$(yq eval ".references[$ref_index].ref" "$config_file" 2>/dev/null)
|
(\$r.env | if . == null then \"\" elif type == \"!!seq\" then join(\",\") else (. | if . == \"null\" then \"\" else . end) end)
|
||||||
|
end
|
||||||
# Check if env is an array or string
|
" "$config_file" 2>/dev/null
|
||||||
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)
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if current environment matches the filter
|
# Check if current environment matches the filter
|
||||||
@@ -463,11 +444,11 @@ install_lib() {
|
|||||||
|
|
||||||
# Try to update
|
# Try to update
|
||||||
if [[ -n "$git_ref" ]]; then
|
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)"
|
log_warn "Failed to update library (continuing with existing version)"
|
||||||
}
|
}
|
||||||
else
|
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)"
|
log_warn "Failed to update library (continuing with existing version)"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user