Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: skip a Terminal PATH entry MXC cannot grant instead of failing every launch (#14129)

Daniel Hanc980574b421f
diff --git a/studio/backend/core/inference/mxc_policy.py b/studio/backend/core/inference/mxc_policy.py
index cd4f685664a..704b831499d 100644
--- a/studio/backend/core/inference/mxc_policy.py
+++ b/studio/backend/core/inference/mxc_policy.py
@@ -203,11 +203,18 @@ def _trusted_terminal_path_dirs(plan) -> list[str]:
return []
from .tools import _is_trusted_windows_program_dir
- return [
- entry
- for entry in (plan.env.get("PATH") or "").split(os.pathsep)
- if entry and os.path.isabs(entry) and _is_trusted_windows_program_dir(entry)
- ]
+ result: list[str] = []
+ for entry in (plan.env.get("PATH") or "").split(os.pathsep):
+ if not (entry and os.path.isabs(entry) and _is_trusted_windows_program_dir(entry)):
+ continue
+ if not os.path.isdir(entry):
+ continue
+ # Skipped, not fatal: one third-party link on PATH (Java 8's java8path, #13656) failed every Terminal launch.
+ try:
+ result.append(_safe_canonical_path(entry, directory = True))
+ except MxcPolicyError as exc:
+ logger.info("Not granting a Terminal PATH entry to the MXC profile: %s", exc)
+ return result
def _runtime_read_roots(executable: str, extra: list[str] = ()) -> list[str]:
diff --git a/studio/backend/tests/test_mxc_dacl_fallback.py b/studio/backend/tests/test_mxc_dacl_fallback.py
index 3a32c23da01..73a435e6dfb 100644
--- a/studio/backend/tests/test_mxc_dacl_fallback.py
+++ b/studio/backend/tests/test_mxc_dacl_fallback.py
@@ -323,6 +323,50 @@ def test_trusted_terminal_path_dirs_are_granted_read_only(monkeypatch, tmp_path)
assert str(untrusted) not in readonly
+def test_reparse_point_on_terminal_path_is_skipped_not_fatal(monkeypatch, tmp_path):
+ # #13656: Java 8 puts a directory symlink (Common Files\Oracle\Java\java8path) on PATH; one
+ # such entry failed every Terminal launch and the live probe, so Sandbox High never enabled.
+ from core.inference import tools
+
+ trusted = tmp_path / "Program Files" / "Git" / "usr" / "bin"
+ target = tmp_path / "Program Files" / "Oracle" / "Java" / "javapath_target"
+ link = tmp_path / "Program Files" / "Oracle" / "Java" / "java8path"
+ trusted.mkdir(parents = True)
+ target.mkdir(parents = True)
+ if os.name == "nt":
+ import subprocess
+
+ # A junction needs no symlink privilege; both are reparse points.
+ subprocess.run(
+ ["cmd.exe", "/d", "/c", "mklink", "/J", str(link), str(target)],
+ check = True,
+ capture_output = True,
+ )
+ else:
+ link.symlink_to(target, target_is_directory = True)
+ monkeypatch.setattr(
+ tools, "_is_trusted_windows_program_dir", lambda path: "Program Files" in path
+ )
+ plan = _policy_plan(tmp_path)
+ plan = os_sandbox.ToolLaunchPlan(
+ argv = plan.argv,
+ workdir = plan.workdir,
+ env = {"PATH": os.pathsep.join([str(link), str(trusted)])},
+ execution_kind = "terminal",
+ )
+ monkeypatch.setattr(mxc_policy.sys, "platform", "win32")
+ monkeypatch.setattr(os_sandbox, "model_library_roots", lambda: ())
+ monkeypatch.setattr(mxc_policy.sys, "prefix", str(tmp_path / "runtime"))
+ monkeypatch.setattr(mxc_policy.sys, "base_prefix", str(tmp_path / "runtime"))
+ monkeypatch.setattr(mxc_policy.site, "getsitepackages", lambda: [])
+ readonly = mxc_policy.build_launch_request(plan, run_id = "fixed")["config"]["filesystem"][
+ "readonlyPaths"
+ ]
+ assert str(trusted) in readonly
+ assert str(link) not in readonly
+ assert str(target) not in readonly
+
+
@pytest.mark.skipif(
not shutil.which("bash") or sys.platform == "win32",
reason = "needs a POSIX bash whose cat comes only from PATH (Git bash finds its own)",