From 8293faec96e3d1441d935a9921ce728ae5e0f15e Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 26 Mar 2025 13:04:27 -0400 Subject: [PATCH] =?UTF-8?q?when=20building=20docker=20images=20there?= =?UTF-8?q?=E2=80=99s=20no=20/.dockerenv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgm.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgm.ts b/pkgm.ts index fb5e7a9..a642c4d 100755 --- a/pkgm.ts +++ b/pkgm.ts @@ -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); }