feat(dev): Windows dev environment for pnpm dev:app:win#1302
feat(dev): Windows dev environment for pnpm dev:app:win#1302senamakel merged 2 commits intotinyhumansai:mainfrom
pnpm dev:app:win#1302Conversation
Promote `scripts/run-dev-win.sh` from a hidden helper into a discoverable
pnpm script and harden it for clean first-run on a fresh Windows
machine. Mirrors the macOS-flavored `dev:app` so Windows devs don't run
the wrong launcher and hit obscure CEF/cargo failures.
Changes:
- `app/package.json` — add `dev:app:win` script that runs the bash
launcher (alongside `dev:app` for macOS).
- `package.json` (root) — proxy the new script through the workspace
filter so `pnpm dev:app:win` works from the repo root too.
- `scripts/setup-chromium-safe-storage.sh` — add a `uname -s != Darwin`
guard so the script no-ops on Windows / Linux instead of failing on
the missing `security` CLI. macOS keychain logic preserved verbatim.
- `scripts/run-dev-win.sh` — auto-bootstrap the MSVC C++ environment so
Tauri's CMake-driven native crates (whisper-rs-sys, etc.) build
without launching from the "x64 Native Tools Command Prompt for VS
2022" first. Specifically:
* Detect when `cl.exe` is missing, locate the latest VS install via
`vswhere.exe`, and run `vcvars64.bat` inside `cmd` to capture the
resulting env into the bash session (PATH gets Windows-to-Unix
conversion; INCLUDE/LIB/LIBPATH stay in Windows form for cl.exe).
* Set `CMAKE_GENERATOR=Ninja` so `cmake` and `cmake --build` agree on
the generator (the previous setup configured with the Visual Studio
generator but invoked Ninja, producing
`ninja: error: loading 'build.ninja'`).
* Pin `CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER` to MSVC's
`link.exe` absolute path so rustc never resolves `link.exe` to
Git's `/usr/bin/link.exe` (a GNU coreutils symlink utility).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a Windows MSVC bootstrap to the Windows dev runner, exposes new Windows dev scripts in root and app package manifests, and adds a macOS-only early exit guard to the Chromium safe-storage setup script. ChangesWindows MSVC Development Toolchain Setup
macOS Platform Isolation
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (shell)
participant Runner as scripts/run-dev-win.sh
participant VSWhere as vswhere.exe
participant VCVars as vcvars64.bat
participant MSVC as MSVC toolchain (cl/link)
participant Build as Cargo/CMake/Ninja
Dev->>Runner: invoke run-dev-win.sh
Runner->>VSWhere: query Visual Studio installations
VSWhere-->>Runner: installation path(s)
Runner->>VCVars: launch vcvars64.bat via temp launcher
VCVars-->>Runner: environment variables (PATH, INCLUDE, LIB, etc.)
Runner->>MSVC: verify cl.exe and link.exe on PATH
MSVC-->>Runner: tool paths confirmed
Runner->>Build: export CARGO_TARGET_..._LINKER and CMAKE_GENERATOR=Ninja
Dev->>Build: proceed with Cargo/CMake build using configured MSVC toolchain
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/run-dev-win.sh`:
- Around line 36-118: The script currently pins link.exe only inside the
bootstrap branch, so when cl.exe is already on PATH the pinning (msvc_cl_dir,
msvc_link_unix, msvc_link_win, and export of
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER) is skipped; move or duplicate the
link discovery/pinning logic to run after the cl.exe bootstrap if-block (use
command -v cl.exe to find cl.exe, compute msvc_cl_dir via dirname "$(command -v
cl.exe)", derive msvc_link_unix/msvc_link_win and export
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER, and prepend msvc_cl_dir to PATH) so
the linker is pinned regardless of whether vcvars64.bat was invoked.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f8eb90d8-604a-405d-b07f-53af9ee42575
📒 Files selected for processing (4)
app/package.jsonpackage.jsonscripts/run-dev-win.shscripts/setup-chromium-safe-storage.sh
CodeRabbit feedback (tinyhumansai#1302): the linker pin lived inside the `if ! command -v cl.exe` block, so when a user launches from a shell that already has `cl.exe` on PATH (e.g. the "x64 Native Tools Command Prompt for VS 2022"), the script skips the bootstrap and the `CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER` export never fires. Cargo then falls back to PATH-based linker resolution, where Git's coreutils `/usr/bin/link.exe` can still shadow MSVC's linker. Move the pin out of the conditional so it runs unconditionally after `cl.exe` is verified to be reachable, regardless of whether the env was just bootstrapped or already inherited from the parent shell.
|
Heads-up: the latest Lychee log: |
Summary
scripts/run-dev-win.shfrom a hidden helper into a discoverablepnpm dev:app:winscript (alongside the macOSdev:app).setup-chromium-safe-storage.sha clean no-op on non-Darwin platforms so the cross-platformdev:apppipeline stops trying to callsecurityon Windows / Linux.Ninja) and the rustc linker (MSVClink.exeabsolute path) so they can't disagree or get shadowed by Git's coreutilslink.exe.Problem
Windows dev today is gated on undocumented setup.
pnpm dev:appis the macOS-flavored launcher (sets$HOME/Library/Caches/tauri-cef, runssetup-chromium-safe-storage.shwhich calls macOS-onlysecurity, setsAPPLE_SIGNING_IDENTITY); it surfaces inpnpm runand looks like the canonical dev entry point. The only Windows-aware launcher (scripts/run-dev-win.sh) lives off-script with no entry inpackage.json, so a Windows dev who follows the obvious path hits a chain of obscure failures:security: command not found(mac keychain CLI invoked unconditionally)ninja: error: loading 'build.ninja'(CMake configured with VS generator but build step invokesninjabecauseCMAKE_MAKE_PROGRAMwas set withoutCMAKE_GENERATOR)/usr/bin/link: extra operand '...rcgu.o'(rustc resolves barelink.exeto Git's coreutils symlink utility instead of MSVC's linker)Even when devs do find
run-dev-win.sh, it required manually launching the "x64 Native Tools Command Prompt for VS 2022" first or the C++ toolchain would be invisible.Solution
Discoverability. Add
dev:app:winto bothapp/package.jsonandpackage.json(root proxy) sopnpm runlists it next todev:app. Same script-naming convention as the existingmacos:*entries.Cross-platform setup-chromium-safe-storage. Add a
[[ "$(uname -s)" != "Darwin" ]] && exit 0guard at the top. macOS Keychain logic is preserved verbatim below the guard. Linux's password store is already configured via--password-store=basicfrom the Tauri shell; Windows uses DPAPI and doesn't need any seeding.Auto-bootstrap MSVC env in run-dev-win.sh. When
cl.exeisn't on PATH, the script:vswhere.exe -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64..batthatcallsvcvars64.batthen dumpsset(a temp.batavoids MSYS's quote-mangling ofcmd //c "call \"...\""invocations).PATHgets Windows-to-Unix conversion per entry,INCLUDE/LIB/LIBPATHstay in Windows form forcl.exe, and the VS-specific vars (VSCMD_*,VCToolsInstallDir,WindowsSdkDir,UCRTVersion, …) come along.cl.exeis reachable; fails fast with a clear error if not.Pin the CMake generator and the linker. After the env load:
export CMAKE_GENERATOR=Ninja— without this, CMake auto-picks the VS generator on Windows (creates.slnfiles), but thecmake --buildstep invokesninjabecauseCMAKE_MAKE_PROGRAMis set, leading to "build.ninja not found".export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=<absolute path to MSVC link.exe>— derived fromdirname "$(command -v cl.exe)". cargo passes this to rustc as-C linker=<path>directly, bypassing PATH lookup entirely so Git's/usr/bin/link.execan never win.Submission Checklist
Impact
pnpm tauri:build:ui/macos:build:*paths, none of which this PR touches).dev:appis unchanged; the chromium-safe-storage script behaves identically on Darwin (the guard is a leading early-exit on non-Darwin only).pnpm dev:app:winmay take an extra few seconds while the MSVC env loads; subsequent runs in the same shell are no-ops becausecl.exeis already detected.Related
Summary by CodeRabbit