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(install): silence the missing AppArmor userns sysctl read (#13125)

Jay Zhouf6fb4cdcbdfb
diff --git a/install.sh b/install.sh
index 556e983a4eb..50553c60e48 100755
--- a/install.sh
+++ b/install.sh
@@ -3355,8 +3355,10 @@ _bwrap_install_command() {
# Wanted, never required: bubblewrap runs Python and Terminal tool calls in an OS sandbox, and without it they run with software safeguards. Optional like the build tools, so it never asks for sudo: installed when the installer already runs as root, otherwise the one command is printed.
_check_linux_tool_sandbox() {
_bw_restrict=""
+ _bw_sysctl="${_BW_USERNS_SYSCTL:-/proc/sys/kernel/apparmor_restrict_unprivileged_userns}"
# read, not cat: a builtin, so a minimal image without coreutils still gets the right advice.
- read -r _bw_restrict <"${_BW_USERNS_SYSCTL:-/proc/sys/kernel/apparmor_restrict_unprivileged_userns}" 2>/dev/null || true
+ # The -r test, not 2>/dev/null: a shell reports a failed < open before that redirection applies.
+ if [ -r "$_bw_sysctl" ]; then read -r _bw_restrict <"$_bw_sysctl" 2>/dev/null || true; fi
if ! command -v bwrap >/dev/null 2>&1 && command -v apt-get >/dev/null 2>&1; then
( _SMART_APT_OPTIONAL=true; _smart_apt_install bubblewrap ) || true
fi
diff --git a/tests/sh/test_linux_tool_sandbox.sh b/tests/sh/test_linux_tool_sandbox.sh
index 77014d191dc..78b75f6ea2d 100755
--- a/tests/sh/test_linux_tool_sandbox.sh
+++ b/tests/sh/test_linux_tool_sandbox.sh
@@ -111,6 +111,13 @@ _out="$(_run 0)"
assert_not_contains "no apt call" "$_out" "APT_CALLED"
assert_contains "reports it works" "$_out" "bubblewrap works"
+echo "=== kernel without the AppArmor userns sysctl: no error for the missing file ==="
+rm -f "$_SYSCTL"
+_out="$(_run 0)"
+assert_not_contains "prints no shell error" "$_out" "No such file"
+assert_contains "reports it works" "$_out" "bubblewrap works"
+: > "$_SYSCTL"
+
echo "=== bubblewrap present, AppArmor restricts user namespaces ==="
rm -f "$_BIN"/*
_mk bwrap 'echo "bwrap: setting up uid map: Permission denied" >&2; exit 1'