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.

fix: skip sudo check on WSL during GGUF export to prevent password prompt hang

Roland Tannousc9fdce63e73a
diff --git a/setup.sh b/setup.sh
index c96ac3a7868..ed594f8cb94 100755
--- a/setup.sh
+++ b/setup.sh
@@ -152,8 +152,19 @@ echo " Installing studio dependencies..."
run_quiet "pip install studio" pip install -r "$SCRIPT_DIR/studio/backend/requirements/studio.txt"
echo "✅ Python dependencies installed"
+# ── 7. WSL: pre-install GGUF build dependencies ──
+# On WSL, sudo requires a password and can't be entered during GGUF export
+# (runs in a non-interactive subprocess). Install build deps here instead.
+if grep -qi microsoft /proc/version 2>/dev/null; then
+ echo ""
+ echo "⚠️ WSL detected — installing build dependencies for GGUF export..."
+ echo " You may be prompted for your password."
+ sudo apt-get update -y
+ sudo apt-get install -y build-essential cmake curl git libcurl4-openssl-dev
+ echo "✅ GGUF build dependencies installed"
+fi
-# ── 7. Add shell alias ──
+# ── 8. Add shell alias ──
# Note: venv activation does NOT persist across terminal sessions.
# This alias hardcodes the venv python path so users don't need to activate.
echo ""
diff --git a/studio/backend/core/export/export.py b/studio/backend/core/export/export.py
index 2ee05090f35..da5b11c60dd 100644
--- a/studio/backend/core/export/export.py
+++ b/studio/backend/core/export/export.py
@@ -18,6 +18,45 @@ from core.inference import get_inference_backend
logger = logging.getLogger(__name__)
+
+def _is_wsl():
+ """Detect if running under Windows Subsystem for Linux."""
+ try:
+ return "microsoft" in open("/proc/version").read().lower()
+ except Exception:
+ return False
+
+
+def _apply_wsl_sudo_patch():
+ """On WSL, monkey-patch do_we_need_sudo() to return False.
+
+ WSL doesn't have passwordless sudo, and do_we_need_sudo() runs
+ `sudo apt-get update` which hangs waiting for a stdin password
+ inside a non-interactive subprocess. setup.sh pre-installs the
+ build dependencies on WSL, so sudo is not needed at runtime.
+ """
+ if not _is_wsl():
+ return
+
+ try:
+ import unsloth_zoo.llama_cpp as llama_cpp_module
+
+ def _wsl_do_we_need_sudo(system_type="debian"):
+ logger.info(
+ "WSL detected — skipping sudo check "
+ "(build deps pre-installed by setup.sh)"
+ )
+ return False
+
+ llama_cpp_module.do_we_need_sudo = _wsl_do_we_need_sudo
+ logger.info(
+ "Applied WSL sudo patch to "
+ "unsloth_zoo.llama_cpp.do_we_need_sudo"
+ )
+ except Exception as e:
+ logger.warning(f"Could not apply WSL sudo patch: {e}")
+
+
# Model card template
MODEL_CARD = \
"""---
@@ -353,6 +392,9 @@ class ExportBackend:
os.chdir(save_directory)
logger.info(f"Changed directory to: {save_directory}")
+ # On WSL, patch out sudo check before llama.cpp build
+ _apply_wsl_sudo_patch()
+
# Now save (will save in current directory)
self.current_model.save_pretrained_gguf(
"model", # Base filename