diff --git a/src/utils/setup/setupPipPack.ts b/src/utils/setup/setupPipPack.ts index 508ebbd7..5cc7d779 100644 --- a/src/utils/setup/setupPipPack.ts +++ b/src/utils/setup/setupPipPack.ts @@ -5,6 +5,7 @@ import { addPath, info } from "@actions/core" import { setupPython } from "../../python/python" import { isBinUptoDate } from "./version" import { join } from "path" +import { mightSudo } from "./sudo" let pip: string | undefined @@ -24,7 +25,10 @@ export async function setupPipPack(name: string, version?: string) { } } - const exit = await exec(pip, ["install", version !== undefined && version !== "" ? `${name}==${version}` : name]) + const exit = await exec(mightSudo(pip), [ + "install", + version !== undefined && version !== "" ? `${name}==${version}` : name, + ]) if (exit !== 0) { throw new Error(`Failed to install ${name} ${version}`) } diff --git a/src/utils/setup/sudo.ts b/src/utils/setup/sudo.ts index 3d63afd6..30154474 100644 --- a/src/utils/setup/sudo.ts +++ b/src/utils/setup/sudo.ts @@ -10,8 +10,12 @@ export function isRoot(): boolean { } export function mightSudo(command: string) { - if (isRoot()) { - return `sudo ${command}` + try { + if (isRoot()) { + return `sudo ${command}` + } + } catch { + // ignore } return command }