fix: pass PYTHONPATH to sudo re-exec so root finds user-installed deps
This commit is contained in:
+8
-1
@@ -114,12 +114,19 @@ def interactive(mode: str | None, output: Path | None, keep_rootfs: bool, yes: b
|
||||
if cfg["_mode"] == "root" and os.geteuid() != 0:
|
||||
console.print("[bold yellow]Root mode selected but not root. Re-executing with sudo...[/]")
|
||||
import subprocess as _sp
|
||||
import site
|
||||
args = [sys.executable, "-m", "euri_mklive", "interactive", "--root"]
|
||||
if keep_rootfs:
|
||||
args.append("--keep-rootfs")
|
||||
if output:
|
||||
args.extend(["-o", str(output)])
|
||||
_sp.run(["sudo"] + args, check=True)
|
||||
env = os.environ.copy()
|
||||
# include user site-packages so root can find click/pyyaml/rich/questionary
|
||||
user_site = site.getusersitepackages()
|
||||
if user_site and os.path.isdir(user_site):
|
||||
existing = env.get("PYTHONPATH", "")
|
||||
env["PYTHONPATH"] = f"{user_site}:{existing}" if existing else user_site
|
||||
_sp.run(["sudo"] + args, check=True, env=env)
|
||||
return
|
||||
|
||||
if cfg["_mode"] == "fakeroot":
|
||||
|
||||
Reference in New Issue
Block a user