Skip to content

Self-hosted AI workspace.

Python

fix(cookbook): set UTF-8 encoding for detached download/serve subprocesses (#1599)

Wes Huber9bd9cf6582b8
diff --git a/routes/cookbook_routes.py b/routes/cookbook_routes.py
index cc245f0eb..e1e4972ea 100644
--- a/routes/cookbook_routes.py
+++ b/routes/cookbook_routes.py
@@ -383,11 +383,15 @@ def setup_cookbook_routes() -> APIRouter:
encoding="utf-8",
)
argv = [os.environ.get("ComSpec", "cmd.exe"), "/c", str(script_path)]
+ env = os.environ.copy()
+ env["PYTHONUTF8"] = "1"
+ env["PYTHONIOENCODING"] = "utf-8"
proc = subprocess.Popen(
argv,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
+ env=env,
**detached_popen_kwargs(),
)
pid_path.write_text(str(proc.pid), encoding="utf-8")