Skip to content

Commit 91fd883

Browse files
committed
when building docker images there’s no /.dockerenv
1 parent 0ab08aa commit 91fd883

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pkgm.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,10 @@ async function query_pkgx(
263263
let cmd = needs_sudo_backwards ? "/usr/bin/sudo" : pkgx;
264264
if (needs_sudo_backwards) {
265265
if (!Deno.env.get("SUDO_USER")) {
266-
if (!Path.root.join(".dockerenv").isFile()) { // if we're running in Docker then screw it, it's fine
267-
//TODO if no SUDO_USER then probs we are a root shell, if so set PKGX_DIR and skip hard link step
268-
throw new Error("SUDO_USER not set, cannot install as root");
269-
} else {
270-
cmd = pkgx;
266+
if (Deno.uid() == 0) {
267+
console.error("%cwarning", 'color:yellow', "installing as root; installing via `sudo` is preferred");
271268
}
269+
cmd = pkgx;
272270
} else {
273271
args.unshift("-u", Deno.env.get("SUDO_USER")!, pkgx);
274272
}

0 commit comments

Comments
 (0)