diff --git a/euri_mklive/cli.py b/euri_mklive/cli.py index 2a8d5fc..6986689 100644 --- a/euri_mklive/cli.py +++ b/euri_mklive/cli.py @@ -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":