Skip to content

Commit

Permalink
fix: install to the user home when using pipx as sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 22, 2024
1 parent bdba352 commit 70ce1ae
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
16 changes: 8 additions & 8 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/actions/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/utils/setup/setupPipPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack"
import { isUbuntu } from "../env/isUbuntu"
import { setupAptPack } from "./setupAptPack"
import { untildifyUser } from "untildify-user"

export type SetupPipPackOptions = {
/** Whether to use pipx instead of pip */
Expand Down Expand Up @@ -56,8 +57,17 @@ export async function setupPipPackWithPython(
const upgradeFlag = upgrade ? (isPipx ? ["upgrade"] : ["install", "--upgrade"]) : ["install"]
const userFlag = !isPipx && user ? ["--user"] : []

const env = process.env

if (isPipx && user) {
// install to user home
env.PIPX_HOME = untildifyUser("~/.local/pipx")
env.PIPX_BIN_DIR = untildifyUser("~/.local/bin")
}

execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
stdio: "inherit",
env,
})
} catch (err) {
info(`Failed to install ${name} via ${pip}: ${err}.`)
Expand Down

0 comments on commit 70ce1ae

Please sign in to comment.