Remove dirname usage

This commit is contained in:
Taiki Endo
2026-04-15 21:04:29 +09:00
parent ff735c627f
commit 6fc852a7b2
3 changed files with 14 additions and 9 deletions

View File

@@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased] ## [Unreleased]
- Implement potential workaround for [windows-11-arm runner bug](https://github.com/actions/partner-runner-images/issues/169) which sometimes causes installation failure.
The issue where this bug affected the startup of bash was addressed in 2.71.2, but we received a report that the same problem seems to occur when starting other commands as well.
- Update `cargo-deny@latest` to 0.19.2. - Update `cargo-deny@latest` to 0.19.2.
## [2.75.13] - 2026-04-15 ## [2.75.13] - 2026-04-15

View File

@@ -57,7 +57,7 @@ runs:
for ($i=1; $i -le 10; $i++) { for ($i=1; $i -le 10; $i++) {
$prev_err_action = $ErrorActionPreference $prev_err_action = $ErrorActionPreference
$ErrorActionPreference = "Continue" $ErrorActionPreference = "Continue"
& bash --noprofile --norc "$env:GITHUB_ACTION_PATH/main.sh" & bash --noprofile --norc "$env:GITHUB_ACTION_PATH\main.sh"
$code = $LASTEXITCODE $code = $LASTEXITCODE
$ErrorActionPreference = "$prev_err_action" $ErrorActionPreference = "$prev_err_action"
if (Test-Path "$env:USERPROFILE\.install-action\init") { if (Test-Path "$env:USERPROFILE\.install-action\init") {

17
main.sh
View File

@@ -563,6 +563,7 @@ fi
install_action_dir="${home}/.install-action" install_action_dir="${home}/.install-action"
tmp_dir="${install_action_dir}/tmp" tmp_dir="${install_action_dir}/tmp"
cargo_bin="${CARGO_HOME:-"${home}/.cargo"}/bin" cargo_bin="${CARGO_HOME:-"${home}/.cargo"}/bin"
cargo_path=$(type -P cargo || true)
# If $CARGO_HOME does not exist, or cargo installed outside of $CARGO_HOME/bin # If $CARGO_HOME does not exist, or cargo installed outside of $CARGO_HOME/bin
# is used ($CARGO_HOME/bin is most likely not included in the PATH), fallback to # is used ($CARGO_HOME/bin is most likely not included in the PATH), fallback to
# $install_action_dir/bin. # $install_action_dir/bin.
@@ -570,15 +571,15 @@ if [[ "${host_os}" == "windows" ]]; then
mkdir -p -- "${install_action_dir}" mkdir -p -- "${install_action_dir}"
# See action.yml. # See action.yml.
touch -- "${install_action_dir}"/init touch -- "${install_action_dir}"/init
if type -P cargo >/dev/null; then if [[ -n "${cargo_path}" ]]; then
info "cargo is located at $(type -P cargo)" info "cargo is located at ${cargo_path}"
cargo_bin=$(dirname -- "$(type -P cargo)") cargo_bin="${cargo_path%/*}"
else else
cargo_bin="${install_action_dir}/bin" cargo_bin="${install_action_dir}/bin"
fi fi
elif [[ ! -e "${cargo_bin}" ]] || [[ "$(type -P cargo || true)" != "${cargo_bin}/cargo"* ]]; then elif [[ ! -e "${cargo_bin}" ]] || [[ "${cargo_path}" != "${cargo_bin}/cargo"* ]]; then
if type -P cargo >/dev/null; then if [[ -n "${cargo_path}" ]]; then
info "cargo is located at $(type -P cargo)" info "cargo is located at ${cargo_path}"
fi fi
# Moving files to /usr/local/bin requires sudo in some environments, so do not use it: https://github.com/taiki-e/install-action/issues/543 # Moving files to /usr/local/bin requires sudo in some environments, so do not use it: https://github.com/taiki-e/install-action/issues/543
cargo_bin="${install_action_dir}/bin" cargo_bin="${install_action_dir}/bin"
@@ -594,7 +595,7 @@ if [[ $# -gt 0 ]]; then
fi fi
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
manifest_dir="$(dirname -- "$0")/manifests" manifest_dir="${GITHUB_ACTION_PATH}/manifests"
# Inputs # Inputs
tool="${INPUT_TOOL:-}" tool="${INPUT_TOOL:-}"
@@ -987,7 +988,7 @@ if [[ ${#unsupported_tools[@]} -gt 0 ]]; then
cargo install "${cargo_args[@]}" "${tool}" cargo install "${cargo_args[@]}" "${tool}"
done done
fi fi
if ! type -P cargo >/dev/null; then if [[ -z "${cargo_path}" ]]; then
_bin_dir=$(canonicalize_windows_path "${home}/.cargo/bin") _bin_dir=$(canonicalize_windows_path "${home}/.cargo/bin")
# TODO: avoid this when already added # TODO: avoid this when already added
info "adding '${_bin_dir}' to PATH" info "adding '${_bin_dir}' to PATH"