Skip to content

Commit 8293fae

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

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkgm.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,14 @@ 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(
268+
"%cwarning",
269+
"color:yellow",
270+
"installing as root; installing via `sudo` is preferred",
271+
);
271272
}
273+
cmd = pkgx;
272274
} else {
273275
args.unshift("-u", Deno.env.get("SUDO_USER")!, pkgx);
274276
}

0 commit comments

Comments
 (0)