From 381a0f2d9f1b12228951347003aff536b6e52898 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 22 Jan 2026 23:21:19 +0530 Subject: [PATCH] Fix paths for bin tools and scoped tools [skip ci] --- src/scripts/tools/add_tools.sh | 7 ++++++- src/scripts/unix.sh | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scripts/tools/add_tools.sh b/src/scripts/tools/add_tools.sh index 9e2c398d..a42afacd 100644 --- a/src/scripts/tools/add_tools.sh +++ b/src/scripts/tools/add_tools.sh @@ -176,10 +176,14 @@ add_tool() { if ! [ -d "$tool_path_dir" ]; then sudo mkdir -p "$tool_path_dir" fi + if ! [ -d "$tool_cache_path_dir" ]; then + sudo mkdir -p "$tool_cache_path_dir" + fi add_path "$tool_path_dir" + add_path "$tool_cache_path_dir" IFS="," read -r -a url <<<"$url" cache_key=$(get_sha256 "${url[0]}" | head -c 16) - cache_path="/tmp/${tool}-${cache_key}" + cache_path="$tool_cache_path_dir/${tool}-${cache_key}" status_code="200" if [ -f "$cache_path" ]; then sudo cp -a "$cache_path" "$tool_path" @@ -199,6 +203,7 @@ add_tool() { fi if [ "$status_code" = "200" ]; then add_tools_helper "$tool" + [ -L "$tool_cache_path_dir/$tool" ] || sudo ln -s "$tool_path" "$tool_cache_path_dir/$tool" 2>/dev/null || true tool_version=$(get_tool_version "$tool" "$ver_param") add_log "${tick:?}" "$tool" "Added $tool $tool_version" else diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index 989b40f6..82c4fa00 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -58,6 +58,7 @@ read_env() { -n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github runner="${runner:-${RUNNER:-$_runner}}" tool_path_dir="${setup_php_tools_dir:-${SETUP_PHP_TOOLS_DIR:-/usr/local/bin}}" + tool_cache_path_dir="${setup_php_tool_cache_dir:-${SETUP_PHP_TOOL_CACHE_DIR:-$RUNNER_TOOL_CACHE/setup-php/tools}}" if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then fail_fast=true @@ -79,6 +80,7 @@ read_env() { export update export ts export tool_path_dir + export tool_cache_path_dir } # Function to create a lock. @@ -169,14 +171,13 @@ get_shell_profile() { # Function to add a path to the PATH variable. add_path() { path_to_add=$1 - [[ ":$PATH:" == *":$path_to_add:"* ]] && return if [[ -n "$GITHUB_PATH" ]]; then - echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1 + printf '%s\n%s' "$path_to_add" "$(grep -v "^${path_to_add}$" "$GITHUB_PATH" 2>/dev/null)" > "$GITHUB_PATH" else profile=$(get_shell_profile) ([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1 fi - export PATH="${PATH:+${PATH}:}$path_to_add" + [[ ":$PATH:" == *":$path_to_add:"* ]] || export PATH="${PATH:+${PATH}:}$path_to_add" } # Function to add environment variables using a PATH.