From 42214beb8ecc8e13301a82d160342aae4b7d85ef Mon Sep 17 00:00:00 2001 From: Fred Heinecke Date: Thu, 19 Dec 2024 12:02:30 -0600 Subject: [PATCH] windows fix --- tools/env-loader/action.yaml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/env-loader/action.yaml b/tools/env-loader/action.yaml index 0ed816c..7cef359 100644 --- a/tools/env-loader/action.yaml +++ b/tools/env-loader/action.yaml @@ -60,21 +60,23 @@ runs: echo "Download complete" # Install the tool - echo "Installing to ${INSTALL_DIR}..." - echo "DEBUG LOG" - echo "command -v sudo: $(command sudo)" - echo "Shell: ${SHELL:-NOT SET}" - if ! command -v sudo; then - # Ensure the sudo "command" exists - echo "Setting alias" - alias sudo="" + # Actual install logic which may need to be ran as root, depending on + # platform + install_tool() { + echo "Installing to ${INSTALL_DIR}..." + mkdir -pv -m 755 "${INSTALL_DIR}" + tar -xzf "${DOWNLOAD_PATH}" -C "${INSTALL_DIR}" "${TOOL_NAME}" + echo "${INSTALL_DIR}" >> "${GITHUB_PATH}" + echo "Installation complete!" + } + + # Run as root via sudo if possible. This cannot be handled via an alias + # because Bash on Windows seems to silently discard `alias sudo=""`. + if command -v sudo > /dev/null; then + sudo install_tool else - echo "Not setting alias" + install_tool fi - sudo mkdir -pv -m 755 "${INSTALL_DIR}" - sudo tar -xzf "${DOWNLOAD_PATH}" -C "${INSTALL_DIR}" "${TOOL_NAME}" - echo "${INSTALL_DIR}" >> "${GITHUB_PATH}" - echo "Installation complete!" # Cleanup rm -rf "${DOWNLOAD_DIR}"