Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,14 @@ async function query_pkgx(
let cmd = needs_sudo_backwards ? "/usr/bin/sudo" : pkgx;
if (needs_sudo_backwards) {
if (!Deno.env.get("SUDO_USER")) {
if (!Path.root.join(".dockerenv").isFile()) { // if we're running in Docker then screw it, it's fine
//TODO if no SUDO_USER then probs we are a root shell, if so set PKGX_DIR and skip hard link step
throw new Error("SUDO_USER not set, cannot install as root");
} else {
cmd = pkgx;
if (Deno.uid() == 0) {
console.error(
"%cwarning",
"color:yellow",
"installing as root; installing via `sudo` is preferred",
);
}
cmd = pkgx;
} else {
args.unshift("-u", Deno.env.get("SUDO_USER")!, pkgx);
}
Expand Down
Loading