Skip to content

[Windows] 建议默认禁用 bundled-sqlcipher-vendored-openssl 以改善开发体验 #441

@AnNingUI

Description

@AnNingUI

📌 软件版本

3.0.6

💻 系统环境

Windows 11

🐛 问题描述

描述

当前配置:

libsqlite3-sys = { version = "0.30.1", features = ["bundled-sqlcipher-vendored-openssl"] }

遇到的问题:
该特性试图在 Windows 上从源码构建 OpenSSL,这引入了对 Perl (MSWin32)NASM 的构建时依赖。

在常见的 Windows 开发环境(如 Git Bash, MSYS2 UCRT64)中,PATH 中优先存在的通常是 Cygwin/Unix 风格的 Perl。OpenSSL 的构建脚本 Configure 无法兼容这种 Perl(因为它无法生成 Windows 风格的反斜杠路径),导致构建直接崩溃:

Error configuring OpenSSL build:
This perl implementation doesn't produce Windows like paths...
This Perl version: ... x86_64-cygwin-thread-multi

虽然安装 Strawberry Perl 可以解决此问题,但这会带来工具链冲突风险(污染 PATH),且导致极长的编译时间。

建议

Target-specific dependency management

建议在 Windows 平台移除 vendored-openssl 特性,转而使用 bundled-sqlcipher

权衡分析(Trade-off):
虽然移除 vendored 后,Windows 开发者需要安装 OpenSSL(如 Win64OpenSSL)并配置环境变量(OPENSSL_DIR, OPENSSL_LIB_DIR, OPENSSL_INCLUDE_DIR),但这属于 Rust 生态在 Windows 下的标准配置流程,且是一次性配置。

相比之下,解决 Perl 版本冲突和编译环境污染是一个非标准的、难以排查的“隐性坑”,对新贡献者极不友好。

推荐修改示例 (src-tauri/Cargo.toml):

[dependencies]
# 移除全局的 libsqlite3-sys 配置

# Windows: 使用 bundled-sqlcipher 
# 注意:这需要开发者安装 OpenSSL 并设置 OPENSSL_DIR 等环境变量,但这比源码编译更稳定。
[target.'cfg(target_os = "windows")'.dependencies]
libsqlite3-sys = { version = "0.30.1", features = ["bundled-sqlcipher"] }

# 非 Windows (Linux/macOS): 保持 vendored 以确保一致性和便携性
[target.'cfg(not(target_os = "windows"))'.dependencies]
libsqlite3-sys = { version = "0.30.1", features = ["bundled-sqlcipher-vendored-openssl"] }

总结

Windows 上的 vendored 构建对宿主 Perl 环境极其敏感。
采用区分平台的依赖策略,将 “不稳定的构建环境问题” 转化为 “标准的文档配置问题”,能显著提高 Windows 开发体验的稳定性。

☄️ 完整的 pnpm tauri info 输出


📷 复现步骤

No response

🚦 期望结果

No response

📝 补充信息

No response

Metadata

Metadata

Assignees

Labels

No fields configured for Feature.

Projects

Status
🚀 正在进行中

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions