Merge pull request #237 from wnlen/dev
Text Encoding / utf8 (push) Successful in 41s

fix: block WSL installs under Windows mount paths
This commit is contained in:
Arvin
2026-04-29 11:05:48 +08:00
committed by GitHub
3 changed files with 29 additions and 0 deletions
+1
View File
@@ -48,6 +48,7 @@ bash install.sh
- 上述命令使用了[加速前缀](https://gh-proxy.org/),如失效可更换其他[可用链接](https://ghproxy.link/)。
- 可通过 `.env` 文件或脚本参数自定义安装选项。
- 在 WSL 环境中,不支持放在 Windows 挂载目录**/mnt/c/**下,请安装到 Linux 原生目录。
------
+1
View File
@@ -14,6 +14,7 @@ source "$PROJECT_DIR/scripts/init/script.sh"
init_project_context "$PROJECT_DIR"
load_env_if_exists
detect_install_scope "${1:-auto}"
ensure_project_not_wsl_windows_mount
ensure_openwrt_install_supported
ensure_required_commands
+27
View File
@@ -233,6 +233,33 @@ init_project_context() {
RESOURCE_DIR="$PROJECT_DIR/resources"
}
is_wsl_env() {
grep -qiE 'microsoft|wsl' /proc/sys/kernel/osrelease 2>/dev/null
}
path_is_wsl_windows_mount() {
local path="$1"
path="$(readlink -f "$path" 2>/dev/null || printf '%s' "$path")"
case "$path" in
/mnt/[a-zA-Z]|/mnt/[a-zA-Z]/*)
return 0
;;
*)
return 1
;;
esac
}
ensure_project_not_wsl_windows_mount() {
if is_wsl_env && path_is_wsl_windows_mount "$PROJECT_DIR"; then
die_state \
"当前项目目录位于 WSL Windows 挂载盘:$PROJECT_DIR" \
"请将项目移动到 Linux 原生目录后重新安装,例如:cd ~ && git clone <repo> clash-for-linux && cd clash-for-linux && bash install.sh"
fi
}
load_env_if_exists() {
local env_file
env_file="$PROJECT_DIR/.env"