Skip to content

fix(resources): Windows/Linux 打包资源目录被误判为开发模式 #318

Closed

Description

@huyengiang101086-spec

问题

ResourceLocator.isPackaged() 用 process.resourcesPath.endsWith('Resources') 检测打包资源目录。macOS 使用 Resources,但 Windows / Linux 使用小写 resources,因此即使 main 已根据 app.isPackaged 设置 FINAGENT_PACKAGED=1,定位器也返回 false。

结果是 getRuntimeRoot() 走源码目录回退,getSkillsDir() 和 Pi cwd 指向错误根目录,getPiExtensionEntry() / getLangSmithExtensionEntry() 寻找开发模式 .ts 源码,而非 extraResources 下的 extensions/.../index.js。

证据

  • 基线:main a6da0059ecafe4426c9a841ec59215655ebcabd1。
  • apps/electron/src/main/index.ts 在 app.isPackaged 时设置上述 flag。
  • 项目使用的 app-builder-lib 26.8.1 的 PlatformPackager.getResourcesDir() 对非 macOS Electron 应用返回 path.join(appOutDir, 'resources')。
  • 本机 Electron 39.8.9 的真实 process.resourcesPath 末段为小写 resources。

最小复现:

process.env.FINAGENT_PACKAGED = '1'
Object.defineProperty(process, 'resourcesPath', {
  value: '/opt/Folio/resources', configurable: true,
})
isPackaged() // 实际 false,预期 true

现有 suffix 检测还会把 NotResources 当成资源目录,建议比较最后一个路径段的完整名称,并兼容两种大小写。

验证与范围

环境:Bun 1.4.2 / Windows 11 (10.0.26200)。新增定位器回归在未修复生产代码上执行:bun test packages/shared/src/resources/resource-locator.test.ts → 5 pass / 2 fail。

真实 Electron main-process smoke 使用 Electron 自身的 resourcesPath,模拟 Folio 的 packaged flag:基线 exit 1(false !== true),修复后 exit 0。未运行完整安装包 E2E,未验证实际扩展加载。

建议只修复资源目录名称判定并增加测试,保持 app.isPackaged flag 门禁及开发模式行为。Codex 在用户授权下准备报告及配套改动。

Activity

  1. huyengiang101086-spec commented on Oct 12, 2026

    @huyengiang101086-spec
    ContributorAuthor

    /claim

  2. github-actions commented on Oct 12, 2026

    @github-actions

    @huyengiang101086-spec 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #318。

  3. added a commit that references this issue on Oct 15, 2026
    d19e8b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

claimedClaimed by a contributor and currently in progress

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions