使用 Electron Builder 构建 appImage 时出现“不允许符号链接操作”错误

Posted

技术标签:

【中文标题】使用 Electron Builder 构建 appImage 时出现“不允许符号链接操作”错误【英文标题】:"Symlink operation not permitted" error when building appImage with Electron Builder 【发布时间】:2020-11-28 09:02:09 【问题描述】:

我是 Electron 的新手,我正在尝试导出我在游戏引擎中制作的游戏。我习惯使用 appImage,因为引擎没有原生导出到 Linux 选项。

我不知道我是否正确,我有点将责任归咎于与图标和/或“符号链接”相关的事情,只是无法正常工作。如果有人可以帮助我解决我的问题或纠正我,我将不胜感激。

这是来自我的终端的日志:

> electron-builder build --linux --x64

  • electron-builder  version=22.8.0 os=5.4.0-26-generic
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=linux arch=x64 electron=9.1.2 appOutDir=dist/linux-unpacked
  • building        target=AppImage arch=x64 file=dist/game-test-1.0.0.AppImage
  ⨯ symlink usr/share/icons/hicolor/256x256/apps/test-app.png /home/voy/shared/electron/test-app/dist/__appImage-x64/test-app.png: operation not permitted
github.com/develar/app-builder/pkg/package-format/appimage.copyIcons.func1.1
    /Volumes/data/Documents/app-builder/pkg/package-format/appimage/appLauncher.go:82
github.com/develar/app-builder/pkg/util.MapAsyncConcurrency.func2
    /Volumes/data/Documents/app-builder/pkg/util/async.go:68
runtime.goexit
    /usr/local/Cellar/go/1.14.2_1/libexec/src/runtime/asm_amd64.s:1373  
  ⨯ /home/voy/shared/electron/test-app/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE  stackTrace=
                                                                                                                                                  Error: /home/voy/shared/electron/test-app/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
                                                                                                                                                      at ChildProcess.<anonymous> (/home/voy/shared/electron/test-app/node_modules/builder-util/src/util.ts:243:14)
                                                                                                                                                      at Object.onceWrapper (events.js:421:26)
                                                                                                                                                      at ChildProcess.emit (events.js:314:20)
                                                                                                                                                      at maybeClose (internal/child_process.js:1051:16)
                                                                                                                                                      at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@1.0.0 build-linux: `electron-builder build --linux --x64`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test-app@1.0.0 build-linux script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/voy/.npm/_logs/2020-08-08T03_53_51_086Z-debug.log

这是我的 package.json:

  "name": "test-app",
  "productName": "game-test",
  "version": "1.0.0",
  "description": "My Electron application description",
  "main": "src/index.js",
  "scripts": 
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\"",
    "build-installer": "electron-builder",
    "build-win": "electron-builder build --win --x64",
    "build-linux": "electron-builder build --linux --x64"
  ,
  "build": 
    "appId": "test-app",
    "win": 
      "target": ["portable"],
      "icon": "src/icon.ico",
      "requestedExecutionLevel": "asInvoker"
    ,
    "linux": 
      "target": ["appImage"],
      "icon": "src/256x256.png",
      "category": "Utility"
    
  ,
  "keywords": [],
  "author": "VoyVivika",
  "license": "MIT",
  "config": 
    "forge": 
      "packagerConfig": ,
      "makers": [
        
          "name": "@electron-forge/maker-squirrel",
          "config": 
            "name": "test_app"
          
        ,
        
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin"
          ]
        ,
        
          "name": "@electron-forge/maker-deb",
          "config": 
            "name": "test_app"
          
        ,
        
          "name": "@electron-forge/maker-rpm",
          "config": 
            "name": "test_app"
          
        
      ]
    
  ,
  "dependencies": 
    "electron-squirrel-startup": "^1.0.0"
  ,
  "devDependencies": 
    "@electron-forge/cli": "^6.0.0-beta.52",
    "@electron-forge/maker-deb": "^6.0.0-beta.52",
    "@electron-forge/maker-rpm": "^6.0.0-beta.52",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.52",
    "@electron-forge/maker-zip": "^6.0.0-beta.52",
    "electron": "9.1.2"
  

【问题讨论】:

【参考方案1】:

好的,所以我发现了我的问题。我在虚拟机中运行我的 Linux,我在共享文件夹上运行命令,我假设虚拟机没有完全访问权限(它是一个共享文件夹,当然它不会),我从直接共享到虚拟机中更本地的位置并且它工作。

【讨论】:

以上是关于使用 Electron Builder 构建 appImage 时出现“不允许符号链接操作”错误的主要内容,如果未能解决你的问题,请参考以下文章

在 electron-forge + webpack 应用程序中使用 electron-builder 构建的应用程序显示空白屏幕

使用 electron-builder 从电子应用程序构建独立的 .exe

如何增加由 electron-builder 构建的应用程序的最大内存限制?

Electron 和 TypeScript (electron-builder):“不能在模块外使用 import 语句”

如何使用 docker 容器为 vue-cli-plugin-electron-builder 生成的 windows 平台构建应用程序

在运行的应用程序中查看 electron-builder 的构建目标