bundle-plugin: @vscode/ripgrep shim 将 rgPath 解析为 app.asar 中的内容,从而破坏了打包的 Electron 应用程序中的文件搜索
作者: ryoma-nakajima创建于 2026年7月28日更新于 2026年9月13日
标签bughelp wantedelectronfile searchbundle
在 `@theia/bundle-plugin` (在 1.73.1 中观察到) 中,esbuild 插件用一个代替程序替换了 `@vscode/ripgrep`: `export const rgPath = require("path").join(__dirname, './native/rg...')`, 将二进制文件复制到打包文件旁边。在使用 electron-builder 打包的应用程序中,打包文件通常位于 `app.asar` 中。Electron 会将 `.node` 文件的 `require()` 重定向到 `app.asar.unpacked`, 但不会重定向 `child_process.spawn()`。代替程序丢弃了 `@vscode/ripgrep` 本身执行的 asar → asar.unpacked 处理,因此 `rgPath` 指向存档内部,每次调用 `spawn()` 都会失败 - 在 Windows 上为 `ENOENT`, 在 macOS 上为 `ENOTDIR`, 文件搜索将默默地返回 0 结果。同一目录中的 `.node` 文件仍然可以正常工作 ( `require()` 被重定向),这使得这种不对称性很难诊断。
内容来源: eclipse-theia/theia