fix: win_start.bat 兼容 .venv 并增加启动前置检查 - #116
Open
hailuohl wants to merge 2 commits into
Open
Conversation
hailuohl
force-pushed
the
fix/win-start-bat-venv-detection
branch
from
September 7, 2026 19:35
c38b193 to
83d8783
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
win_start.bat此前硬编码激活.\backend\venv\,但 README「安装后端依赖」一节推荐的流程是pip install uv; uv sync(生成的是backend\.venv\)。照官方文档操作后,双击一键启动脚本直接失败(Activate.bat 路径不存在),README 第 315 行还明确承诺"windows用户直接双击运行 win_start.bat 即可启动项目"。改动:
backend\venv(保持现有用户路径不变),不存在则回退backend\.venv(uv sync 产物);两者都没有时给出明确的中文指引(提示执行cd backend+uv sync)后退出,不再无声闪退。where检查redis-server与pnpm是否在 PATH,缺失时输出对应安装指引(Redis 的 Windows 下载地址 /npm install -g pnpm)并中止。.\.venv\Scripts\Activate.ps1。技术说明
goto跳转而非括号块:实测发现 cmd 解析含中文的括号块时会把后续echo行拆断执行('Windows' is not recognized),改为 goto 结构后稳定。此问题已在 Windows 10 实机复现并验证修复。if exist+if not defined链式判断,无嵌套括号块。chcp 65001原有约定不变。验证
在 Windows 10 实机(Git Bash 环境构造测试副本、注释 start 行避免弹窗)覆盖 4 个场景:
backend\.venv(uv sync 用户)backend\.venv(原版此场景直接失败)venv与.venv并存venv,与现有行为一致中文输出、URL 显示、错误退出码(exit /b 1)均验证正常。