electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.68k stars 1.74k forks source link

build arm64 snap on x64 machine #5626

Open LabhanshAgrawal opened 3 years ago

LabhanshAgrawal commented 3 years ago

when I try to build an arm64 snap on my laptop (ubuntu 20.04 x64) and github actions (ubuntu 18.04 x64) I get the below error

⨯ snapcraft does not currently support building arm64 on amd64  
  ⨯ /home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE  stackTrace=
Error: /home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
at ChildProcess.<anonymous> (/home/labhansh/hyper/node_modules/builder-util/src/util.ts:243:14)
at Object.onceWrapper (node:events:483:26)
at ChildProcess.emit (node:events:376:20)
at maybeClose (node:internal/child_process:1063:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
error Command failed with exit code 1.

Is there any way I can build arm64 snap on x64 machine?

mmaietta commented 3 years ago

Can you please run electron-builder with DEBUG='electron-builder' env var set? Need more details in what's going on.

LabhanshAgrawal commented 3 years ago
  • electron-builder  version=22.10.4 os=5.8.0-43-generic
  • loaded configuration  file=/home/labhansh/hyper/electron-builder.json
  • effective config  config=
                        directories:
                          output: dist
                          buildResources: build
                          app: target
                        $schema: 'http://json.schemastore.org/electron-builder'
                        appId: co.zeit.hyper
                        extraResources:
                          - filter:
                              - ./bin/yarn-standalone.js
                              - ./bin/cli.js
                          - from: './build/${os}/'
                            to: ./bin/
                            filter:
                              - hyper*
                        linux:
                          category: TerminalEmulator
                          target:
                            - target: snap
                              arch:
                                - arm64
                        win:
                          target:
                            - nsis
                          rfc3161TimeStampServer: 'http://timestamp.comodoca.com'
                        nsis:
                          include: build/win/installer.nsh
                        mac:
                          target:
                            target: default
                            arch:
                              - x64
                              - arm64
                          artifactName: '${productName}-${version}-${os}-${arch}.${ext}'
                          category: public.app-category.developer-tools
                          extendInfo:
                            CFBundleDocumentTypes:
                              - CFBundleTypeName: Folders
                                CFBundleTypeRole: Viewer
                                LSHandlerRank: Alternate
                                LSItemContentTypes:
                                  - public.folder
                                  - com.apple.bundle
                                  - com.apple.package
                                  - com.apple.resolvable
                              - CFBundleTypeName: UnixExecutables
                                CFBundleTypeRole: Shell
                                LSHandlerRank: Alternate
                                LSItemContentTypes:
                                  - public.unix-executable
                            NSAppleEventsUsageDescription: An application in Hyper wants to use AppleScript.
                            NSCalendarsUsageDescription: An application in Hyper wants to access Calendar data.
                            NSCameraUsageDescription: An application in Hyper wants to use the Camera.
                            NSContactsUsageDescription: An application in Hyper wants to access your Contacts.
                            NSDesktopFolderUsageDescription: An application in Hyper wants to access the Desktop folder.
                            NSDocumentsFolderUsageDescription: An application in Hyper wants to access the Documents folder.
                            NSDownloadsFolderUsageDescription: An application in Hyper wants to access the Downloads folder.
                            NSFileProviderDomainUsageDescription: An application in Hyper wants to access files managed by a file provider.
                            NSFileProviderPresenceUsageDescription: An application in Hyper wants to be informed when other apps access files that it manages.
                            NSLocationUsageDescription: An application in Hyper wants to access your location information.
                            NSMicrophoneUsageDescription: An application in Hyper wants to use your microphone.
                            NSMotionUsageDescription: An application in Hyper wants to use the device’s accelerometer.
                            NSNetworkVolumesUsageDescription: An application in Hyper wants to access files on a network volume.
                            NSPhotoLibraryUsageDescription: An application in Hyper wants to access the photo library.
                            NSRemindersUsageDescription: An application in Hyper wants to access your reminders.
                            NSRemovableVolumesUsageDescription: An application in Hyper wants to access files on a removable volume.
                            NSSpeechRecognitionUsageDescription: An application in Hyper wants to send user data to Apple’s speech recognition servers.
                            NSSystemAdministrationUsageDescription: The operation being performed by an application in Hyper requires elevated permission.
                          darkModeSupport: true
                        deb:
                          afterInstall: ./build/linux/after-install.tpl
                        rpm:
                          afterInstall: ./build/linux/after-install.tpl
                        snap:
                          confinement: classic
                        protocols:
                          name: ssh URL
                          schemes:
                            - ssh

  • two package.json structure is used  devPackageFile=/home/labhansh/hyper/package.json appPackageFile=/home/labhansh/hyper/target/package.json
  • writing effective config  file=dist/builder-effective-config.yaml
  • spawning        command=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder node-dep-tree --dir /home/labhansh/hyper/target
  • unresolved deps  unresolved=native-reg nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=fsevents nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=normalize-path nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=is-glob nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=picomatch nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=atomicallydot-propjson-schema-typedmake-dirajvdebounce-fnenv-pathsonetimepkg-upsemver nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=semver nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • unresolved deps  unresolved=memlcid nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=human-signalsonetimesignal-exitstrip-final-newlinemerge-stream nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=onetime nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • unresolved deps  unresolved=pump nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=once nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=shebang-commandwhichpath-key nodeModuleDir=/home/labhansh/hyper/target/node_modules/os-locale/node_modules round=0
  • unresolved deps  unresolved=path-key nodeModuleDir=/home/labhansh/hyper/target/node_modules round=1
  • unresolved deps  unresolved=isexe nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=mimic-fn nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=simple-swizzle nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=loose-envifyobject-assignscheduler nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=loose-envifyobject-assign nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=loose-envifyobject-assign nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • unresolved deps  unresolved=default-shell nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=signal-exit nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=nice-trypath-keyshebang-commandwhich nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=path-key nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • unresolved deps  unresolved=isexe nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=pump nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=path-key nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=universalify nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=graceful-fs nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=lodash nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=lodash nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • unresolved deps  unresolved=protocols nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=protocolsis-ssh nodeModuleDir=/home/labhansh/hyper/node_modules round=0
  • unresolved deps  unresolved=loose-envifyobject-assign nodeModuleDir=/home/labhansh/hyper/target/node_modules round=0
  • unresolved deps  unresolved=loose-envifyobject-assign nodeModuleDir=/home/labhansh/hyper/node_modules round=1
  • exited          command=app-builder code=0 pid=5057 out=[{"dir":"/home/labhansh/hyper/node_modules","deps":[{"name":"end-of-stream","version":"1.4.4"},{"name":"graceful-fs","version":"4.2.4","optional":true},{"name":"is-extglob","version":"2.1.1"},{"name":"is-glob","version":"4.0.1"},{"name":"is-ssh","version":"1.3.2"},{"name":"isexe","version":"2.0.0"},{"name":"js-tokens","version":"4.0.0"},{"name":"lodash","version":"4.17.20"},{"name":"loose-envify","version":"1.4.0"},{"name":"lru-cache","version":"6.0.0"},{"name":"mimic-fn","version":"3.1.0"},{"name":"normalize-path","version":"3.0.0"},{"name":"object-assign","version":"4.1.1"},{"name":"once","version":"1.4.0"},{"name":"onetime","version":"5.1.2"},{"name":"path-key","version":"3.1.1"},{"name":"picomatch","version":"2.2.2"},{"name":"protocols","version":"1.4.8"},{"name":"pump","version":"3.0.0"},{"name":"semver","version":"7.3.4"},{"name":"signal-exit","version":"3.0.3"},{"name":"universalify","version":"1.0.0"},{"name":"wrappy","version":"1.0.2"},{"name":"yallist","version":"4.0.0"}]},{"dir":"/home/labhansh/hyper/target/node_modules","deps":[{"name":"ajv","version":"7.0.3"},{"name":"ansi-regex","version":"4.1.0"},{"name":"anymatch","version":"3.1.1"},{"name":"async-retry","version":"1.3.1"},{"name":"at-least-node","version":"1.0.0"},{"name":"atomically","version":"1.7.0"},{"name":"binary-extensions","version":"2.1.0"},{"name":"braces","version":"3.0.2"},{"name":"chokidar","version":"3.5.1"},{"name":"color","version":"3.1.3"},{"name":"color-convert","version":"1.9.3"},{"name":"color-name","version":"1.1.3"},{"name":"color-string","version":"1.5.4"},{"name":"conf","version":"9.0.0"},{"name":"convert-css-color-name-to-hex","version":"0.1.1"},{"name":"cross-spawn","version":"6.0.5"},{"name":"css-color-names","version":"0.0.3"},{"name":"debounce-fn","version":"4.0.0"},{"name":"default-shell","version":"1.0.1"},{"name":"dot-prop","version":"6.0.1"},{"name":"electron-fetch","version":"1.7.3"},{"name":"electron-is-dev","version":"1.2.0"},{"name":"electron-store","version":"7.0.1"},{"name":"encoding","version":"0.1.13"},{"name":"end-of-stream","version":"1.4.4"},{"name":"env-paths","version":"2.2.0"},{"name":"execa","version":"1.0.0"},{"name":"fast-deep-equal","version":"3.1.3"},{"name":"file-uri-to-path","version":"2.0.0"},{"name":"fill-range","version":"7.0.1"},{"name":"find-up","version":"3.0.0"},{"name":"fs-extra","version":"9.1.0"},{"name":"get-stream","version":"4.1.0"},{"name":"git-describe","version":"4.0.4"},{"name":"glob-parent","version":"5.1.1"},{"name":"graceful-fs","version":"4.2.4"},{"name":"human-signals","version":"1.1.1"},{"name":"iconv-lite","version":"0.6.2"},{"name":"inherits","version":"2.0.4"},{"name":"invert-kv","version":"3.0.1"},{"name":"is-arrayish","version":"0.3.2"},{"name":"is-binary-path","version":"2.1.0"},{"name":"is-css-color-name","version":"0.1.3"},{"name":"is-extglob","version":"2.1.1"},{"name":"is-glob","version":"4.0.1"},{"name":"is-number","version":"7.0.0"},{"name":"is-obj","version":"2.0.0"},{"name":"is-ssh","version":"1.3.2"},{"name":"is-stream","version":"1.1.0"},{"name":"isexe","version":"2.0.0"},{"name":"js-tokens","version":"4.0.0"},{"name":"json-schema-traverse","version":"1.0.0"},{"name":"json-schema-typed","version":"7.0.3"},{"name":"jsonfile","version":"6.1.0"},{"name":"lcid","version":"3.1.1"},{"name":"locate-path","version":"3.0.0"},{"name":"lodash","version":"4.17.20"},{"name":"loose-envify","version":"1.4.0"},{"name":"lru-cache","version":"6.0.0"},{"name":"make-dir","version":"3.1.0"},{"name":"map-age-cleaner","version":"0.1.3"},{"name":"mem","version":"5.1.1"},{"name":"merge-stream","version":"2.0.0"},{"name":"mimic-fn","version":"2.1.0"},{"name":"mkdirp","version":"1.0.4"},{"name":"ms","version":"2.1.3"},{"name":"nan","version":"2.14.2"},{"name":"nice-try","version":"1.0.5"},{"name":"node-pty","version":"0.10.0"},{"name":"normalize-path","version":"3.0.0"},{"name":"normalize-url","version":"3.3.0"},{"name":"npm-run-path","version":"2.0.2"},{"name":"object-assign","version":"4.1.1"},{"name":"once","version":"1.4.0"},{"name":"onetime","version":"5.1.2"},{"name":"os-locale","version":"5.0.0"},{"name":"p-defer","version":"1.0.0"},{"name":"p-finally","version":"1.0.0"},{"name":"p-is-promise","version":"2.1.0"},{"name":"p-limit","version":"2.3.0"},{"name":"p-locate","version":"3.0.0"},{"name":"p-try","version":"2.2.0"},{"name":"parse-path","version":"4.0.2"},{"name":"parse-url","version":"5.0.2"},{"name":"path-exists","version":"3.0.0"},{"name":"path-key","version":"2.0.1"},{"name":"picomatch","version":"2.2.2"},{"name":"pify","version":"5.0.0"},{"name":"pkg-up","version":"3.1.0"},{"name":"protocols","version":"1.4.8"},{"name":"pump","version":"3.0.0"},{"name":"punycode","version":"2.1.1"},{"name":"queue","version":"6.0.2"},{"name":"react","version":"17.0.1"},{"name":"react-dom","version":"17.0.1"},{"name":"readdirp","version":"3.5.0"},{"name":"require-from-string","version":"2.0.2"},{"name":"retry","version":"0.12.0"},{"name":"safer-buffer","version":"2.1.2"},{"name":"scheduler","version":"0.20.1"},{"name":"semver","version":"7.3.4"},{"name":"shebang-command","version":"1.2.0"},{"name":"shebang-regex","version":"1.0.0"},{"name":"shell-env","version":"3.0.1"},{"name":"signal-exit","version":"3.0.3"},{"name":"simple-swizzle","version":"0.2.2"},{"name":"strip-ansi","version":"5.2.0"},{"name":"strip-eof","version":"1.0.0"},{"name":"strip-final-newline","version":"2.0.0"},{"name":"to-regex-range","version":"5.0.1"},{"name":"type-fest","version":"0.20.2"},{"name":"universalify","version":"2.0.0"},{"name":"uri-js","version":"4.4.0"},{"name":"uuid","version":"8.3.2"},{"name":"which","version":"1.3.1"},{"name":"wrappy","version":"1.0.2"},{"name":"yallist","version":"4.0.0"}]},{"dir":"/home/labhansh/hyper/node_modules/onetime/node_modules","deps":[{"name":"mimic-fn","version":"2.1.0"}]},{"dir":"/home/labhansh/hyper/target/node_modules/color-string/node_modules","deps":[{"name":"color-name","version":"1.1.4"}]},{"dir":"/home/labhansh/hyper/target/node_modules/cross-spawn/node_modules","deps":[{"name":"semver","version":"5.7.1"}]},{"dir":"/home/labhansh/hyper/target/node_modules/debounce-fn/node_modules","deps":[{"name":"mimic-fn","version":"3.1.0"}]},{"dir":"/home/labhansh/hyper/target/node_modules/git-describe/node_modules","deps":[{"name":"semver","version":"5.7.1","optional":true}]},{"dir":"/home/labhansh/hyper/target/node_modules/is-css-color-name/node_modules","deps":[{"name":"css-color-names","version":"0.0.2"}]},{"dir":"/home/labhansh/hyper/target/node_modules/make-dir/node_modules","deps":[{"name":"semver","version":"6.3.0"}]},{"dir":"/home/labhansh/hyper/target/node_modules/os-locale/node_modules","deps":[{"name":"cross-spawn","version":"7.0.3"},{"name":"execa","version":"4.1.0"},{"name":"get-stream","version":"5.2.0"},{"name":"is-stream","version":"2.0.0"},{"name":"npm-run-path","version":"4.0.1"},{"name":"path-key","version":"3.1.1"},{"name":"shebang-command","version":"2.0.0"},{"name":"shebang-regex","version":"3.0.0"},{"name":"which","version":"2.0.2"}]}]
  • spawning        command=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder rebuild-node-modules cwd=/home/labhansh/hyper/target
  • map async       taskCount=10
  • map async       taskCount=1
  • map async       taskCount=1
  • map async       taskCount=1
  • map async       taskCount=1
  • map async       taskCount=1
  • map async       taskCount=9
  • map async       taskCount=24
  • map async       taskCount=1
  • map async       taskCount=117
  • map async       taskCount=1
  • rebuilding native dependencies  dependencies=node-pty@0.10.0 platform=linux arch=arm64
  • map async       taskCount=1
  • map async       taskCount=1
  • rebuilding native dependency  name=node-pty version=0.10.0
  • execute command  command=/home/labhansh/.nvm/versions/node/v15.5.1/bin/node /usr/share/yarn/bin/yarn.js run install workingDirectory=/home/labhansh/hyper/target/node_modules/node-pty
  • command executed  executable=/home/labhansh/.nvm/versions/node/v15.5.1/bin/node
                      out=$ node scripts/install.js
    make: Entering directory '/home/labhansh/hyper/target/node_modules/node-pty/build'
      CXX(target) Release/obj.target/pty/src/unix/pty.o
      SOLINK_MODULE(target) Release/obj.target/pty.node
      COPY Release/pty.node
    make: Leaving directory '/home/labhansh/hyper/target/node_modules/node-pty/build'
    $ node scripts/post-install.js

                      errorOut=gyp info it worked if it ends with ok
    gyp info using node-gyp@7.1.2
    gyp info using node@15.5.1 | linux | x64
    gyp info find Python using Python version 3.8.5 found at "/usr/bin/python3"
    gyp info spawn /usr/bin/python3
    gyp info spawn args [
    gyp info spawn args   '/home/labhansh/.nvm/versions/node/v15.5.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
    gyp info spawn args   'binding.gyp',
    gyp info spawn args   '-f',
    gyp info spawn args   'make',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/labhansh/hyper/target/node_modules/node-pty/build/config.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/labhansh/.nvm/versions/node/v15.5.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
    gyp info spawn args   '-I',
    gyp info spawn args   '/home/labhansh/.electron-gyp/11.2.3/include/node/common.gypi',
    gyp info spawn args   '-Dlibrary=shared_library',
    gyp info spawn args   '-Dvisibility=default',
    gyp info spawn args   '-Dnode_root_dir=/home/labhansh/.electron-gyp/11.2.3',
    gyp info spawn args   '-Dnode_gyp_dir=/home/labhansh/.nvm/versions/node/v15.5.1/lib/node_modules/npm/node_modules/node-gyp',
    gyp info spawn args   '-Dnode_lib_file=/home/labhansh/.electron-gyp/11.2.3/<(target_arch)/node.lib',
    gyp info spawn args   '-Dmodule_root_dir=/home/labhansh/hyper/target/node_modules/node-pty',
    gyp info spawn args   '-Dnode_engine=v8',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.'
    gyp info spawn args ]
    gyp info spawn make
    gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    In file included from /home/labhansh/.electron-gyp/11.2.3/include/node/node.h:67,
                     from ../../nan/nan.h:56,
                     from ../src/unix/pty.cc:20:
    /home/labhansh/.electron-gyp/11.2.3/include/node/v8.h:9182:75: warning: ‘v8::MicrotasksCompletedCallback’ is deprecated: Use *WithData version. [-Wdeprecated-declarations]
     9182 |   void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
          |                                                                           ^
    /home/labhansh/.electron-gyp/11.2.3/include/node/v8.h:7384:16: note: declared here
     7384 | typedef void (*MicrotasksCompletedCallback)(Isolate*);
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/labhansh/.electron-gyp/11.2.3/include/node/v8.h:9190:78: warning: ‘v8::MicrotasksCompletedCallback’ is deprecated: Use *WithData version. [-Wdeprecated-declarations]
     9190 |   void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback);
          |                                                                              ^
    /home/labhansh/.electron-gyp/11.2.3/include/node/v8.h:7384:16: note: declared here
     7384 | typedef void (*MicrotasksCompletedCallback)(Isolate*);
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/unix/pty.cc: In function ‘void pty_after_waitpid(uv_async_t*)’:
    ../src/unix/pty.cc:512:43: warning: ‘void* memset(void*, int, size_t)’ writing to an object of type ‘class Nan::Persistent<v8::Function>’ with no trivial copy-assignment [-Wclass-memaccess]
      512 |   memset(&baton->cb, -1, sizeof(baton->cb));
          |                                           ^
    In file included from ../../nan/nan.h:405,
                     from ../src/unix/pty.cc:20:
    ../../nan/nan_persistent_12_inl.h:12:40: note: ‘class Nan::Persistent<v8::Function>’ declared here
       12 | template<typename T, typename M> class Persistent :
          |                                        ^~~~~~~~~~
    In file included from ../../nan/nan.h:56,
                     from ../src/unix/pty.cc:20:
    ../src/unix/pty.cc: At global scope:
    /home/labhansh/.electron-gyp/11.2.3/include/node/node.h:614:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
      614 |       (node::addon_register_func) (regfunc),                          \
          |                                           ^
    /home/labhansh/.electron-gyp/11.2.3/include/node/node.h:648:3: note: in expansion of macro ‘NODE_MODULE_X’
      648 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
          |   ^~~~~~~~~~~~~
    ../src/unix/pty.cc:734:1: note: in expansion of macro ‘NODE_MODULE’
      734 | NODE_MODULE(pty, init)
          | ^~~~~~~~~~~
    gyp info ok 

  • exited          command=app-builder code=0 pid=5063
  • packaging       platform=linux arch=arm64 electron=11.2.3 appOutDir=dist/linux-arm64-unpacked
  • spawning        command=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder unpack-electron --configuration [{"platform":"linux","arch":"arm64","version":"11.2.3"}] --output /home/labhansh/hyper/dist/linux-arm64-unpacked --distMacOsAppName Electron.app
  • map async       taskCount=2
  • map async       taskCount=1
  • map async       taskCount=73
  • exited          command=app-builder code=0 pid=5155
  • copying files using pattern  matcher=from: /home/labhansh/hyper, to: /home/labhansh/hyper/dist/linux-arm64-unpacked/resources, patterns: bin/yarn-standalone.js, bin/cli.js
  • copying         src=/home/labhansh/hyper destination=/home/labhansh/hyper/dist/linux-arm64-unpacked/resources
  • copying files using pattern  matcher=from: /home/labhansh/hyper/build/linux, to: /home/labhansh/hyper/dist/linux-arm64-unpacked/resources/bin, patterns: hyper*
  • copying         src=/home/labhansh/hyper/build/linux destination=/home/labhansh/hyper/dist/linux-arm64-unpacked/resources/bin
  • building        target=snap arch=arm64 file=dist/hyper_3.1.0-canary.4_arm64.snap
  • spawning        command=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder icon --format set --root /home/labhansh/hyper/build --root /home/labhansh/hyper --out /home/labhansh/hyper/dist/.icon-set --fallback-input build --fallback-input /home/labhansh/hyper/node_modules/app-builder-lib/templates/icons/electron-linux
  • path doesn't exist  path=/home/labhansh/hyper/build/icons
  • path doesn't exist  path=/home/labhansh/hyper/icons
  • path doesn't exist  path=/home/labhansh/hyper/build/icon.png
  • path doesn't exist  path=/home/labhansh/hyper/icon.png
  • path resolved   path=/home/labhansh/hyper/build/icon.icns outputFormat=set
  • map async       taskCount=1
  • found existing  path=/home/labhansh/.cache/electron-builder/appimage/appimage-12.0.1
  • execute command  command=/home/labhansh/.cache/electron-builder/appimage/appimage-12.0.1/linux-x64/opj_decompress -quiet -i /home/labhansh/hyper/dist/.icon-set/icon_ic10.jp2 -o /home/labhansh/hyper/dist/.icon-set/icon_1024.png
                     workingDirectory=
  • command executed  executable=/home/labhansh/.cache/electron-builder/appimage/appimage-12.0.1/linux-x64/opj_decompress
  • map async       taskCount=7
  • exited          command=app-builder code=0 pid=5163 out={"icons":[{"file":"/home/labhansh/hyper/dist/.icon-set/icon_16x16.png","size":16},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_32x32.png","size":32},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_48x48.png","size":48},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_64x64.png","size":64},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_128x128.png","size":128},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_256x256.png","size":256},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_512x512.png","size":512},{"file":"/home/labhansh/hyper/dist/.icon-set/icon_1024.png","size":1024}],"isFallback":false}
  • spawning        command=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder snap --app /home/labhansh/hyper/dist/linux-arm64-unpacked --stage /home/labhansh/hyper/dist/__snap-arm64 --arch arm64 --output /home/labhansh/hyper/dist/hyper_3.1.0-canary.4_arm64.snap --executable hyper --icon /home/labhansh/hyper/dist/.icon-set/icon_1024.png --extraAppArgs=--no-sandbox
  • copy files      from=/home/labhansh/hyper/dist/.icon-set/icon_1024.png to=/home/labhansh/hyper/dist/__snap-arm64/snap/gui/icon.png isUseHardLinks=true
  • copy files      from=/home/labhansh/hyper/dist/linux-arm64-unpacked to=/home/labhansh/hyper/dist/__snap-arm64/app isUseHardLinks=true
  ⨯ snapcraft does not currently support building arm64 on amd64  
  • exited          command=app-builder code=1 pid=5170
  • async task error  error=/home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
  ⨯ /home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE  stackTrace=
                                                                                                                                    Error: /home/labhansh/hyper/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
                                                                                                                                        at ChildProcess.<anonymous> (/home/labhansh/hyper/node_modules/builder-util/src/util.ts:243:14)
                                                                                                                                        at Object.onceWrapper (node:events:483:26)
                                                                                                                                        at ChildProcess.emit (node:events:376:20)
                                                                                                                                        at maybeClose (node:internal/child_process:1063:16)
                                                                                                                                        at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
mmaietta commented 3 years ago

Would you be willing to install electron-installer-snap package and try this script to execute against the linux-arm64-unpacked dir? https://github.com/electron-userland/electron-installer-snap/blob/c09ed77b93bbf7c2fd35a34b488c5be6416cd630/src/index.d.ts#L15-L24

const snapPath = await snap({src: linuxArm64UnpackedDir, arch: 'arm64'})

Does building snap for other architectures work for you? I'm trying to isolate if this is just electron-builder, another package, env-related, or just snap x64/arm64 cross-compilation

LabhanshAgrawal commented 3 years ago

I'm getting this error

Packaging app for platform linux arm64 using electron v11.2.3
The browser-sandbox feature will trigger a manual review in the Snap store.
/snap/multipass/3387/bin/launch-multipass: 3: export: /usr/sbin: bad variable name
/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99
                reject(new ExitCodeError(cmd, args, code, stdout, stderr));
                       ^

ExitCodeError: Command failed with a non-zero return code (2):
/snap/bin/snapcraft snap --target-arch=arm64 --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap
    at ChildProcess.<anonymous> (/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99:24)
    at ChildProcess.emit (node:events:376:20)
    at maybeClose (node:internal/child_process:1063:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5) {
  cmd: '/snap/bin/snapcraft',
  args: [
    'snap',
    '--target-arch=arm64',
    '--output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap'
  ],
  stdout: '',
  stderr: '',
  code: 2
}

I ran this

const packager = require('electron-packager')
const snap = require('electron-installer-snap')

const arch = 'arm64'

packager({ dir: './target', platform: 'linux', arch: arch })
    .then(paths => snap({ src: paths[0], arch: arch }))
    .then(snapPath => {
        console.log(`Created snap at ${snapPath}!`)
    })

I'm able to create x64 snap using electron-builder, just having issues with arm64

LabhanshAgrawal commented 3 years ago

If I run electron-installer-snap directly against the linux arm64 unpacked dir I get

node:internal/process/promises:227
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[Error: ENOENT: no such file or directory, open '/home/labhansh/hyper/dist/linux-arm64-unpacked/version'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/labhansh/hyper/dist/linux-arm64-unpacked/version'
}
mmaietta commented 3 years ago

[Error: ENOENT: no such file or directory, open '/home/labhansh/hyper/dist/linux-arm64-unpacked/version'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/home/labhansh/hyper/dist/linux-arm64-unpacked/version' }

Hmmm, I don't see anything in their source code looking for a 'version' file. https://github.com/electron-userland/electron-installer-snap/search?q=version I'm curious where that error is being spat out from.

Can you try running with env var DEBUG='electron-*'?

Also, it might we worth trying to create a stubbed version text file, maybe with just your app version in it? Then rerun the script directly as you mentioned. Honestly, I've never worked with snaps before so I'm a bit out of my element here, happy to investigate where I can though.

LabhanshAgrawal commented 3 years ago

electron-packager created a new folder and it had a version file with the electron version (11.2.3) so I copied that and ran it again. I got basically the same output as earlier. Below is the output when I run with the debug=electron-* thing

  electron-installer-snap:default_args Reading package metadata from /home/labhansh/hyper/dist/linux-arm64-unpacked/resources/app.asar +0ms
  electron-installer-common:desktop Creating desktop file at /tmp/electron-snap-3555EIoX5MRssVHJ/snap/gui/hyper.desktop +0ms
  electron-installer-common:template Generating template from /home/labhansh/hyper/node_modules/electron-installer-snap/resources/desktop.ejs +0ms
  electron-installer-common:template Generated template from /home/labhansh/hyper/node_modules/electron-installer-snap/resources/desktop.ejs
  electron-installer-common:template [Desktop Entry]
  electron-installer-common:template Name=Hyper
  electron-installer-common:template Exec=hyper %U
  electron-installer-common:template Icon=${SNAP}/meta/gui/icon.png
  electron-installer-common:template Type=Application
  electron-installer-common:template StartupNotify=true
  electron-installer-common:template 
  electron-installer-common:template  +3ms
  electron-installer-snap:yaml Loading YAML template /home/labhansh/hyper/node_modules/electron-installer-snap/resources/snapcraft.yaml +0ms
  electron-installer-snap:yaml Replacing browser-support plug with browser-sandbox +68ms
The browser-sandbox feature will trigger a manual review in the Snap store.
  electron-installer-snap:yaml Writing new YAML file /tmp/electron-snap-3555EIoX5MRssVHJ/snap/snapcraft.yaml +4ms
  electron-installer-snap:snapcraft Running '/snap/bin/snapcraft snap --target-arch=arm64 --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap' in /tmp/electron-snap-3555EIoX5MRssVHJ +0ms
Ignoring '--target-arch' flag.  This flag requires --destructive-mode and is unsupported with Multipass and LXD build providers.
Launching a VM.
Build environment is in unknown state, cleaning first.
/snap/multipass/3387/bin/launch-multipass: 3: export: /usr/sbin: bad variable name
/snap/multipass/3387/bin/launch-multipass: 3: export: /usr/sbin: bad variable name
An error occurred with the instance when trying to launch with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.
/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99
                reject(new ExitCodeError(cmd, args, code, stdout, stderr));
                       ^

ExitCodeError: Command failed with a non-zero return code (2):
/snap/bin/snapcraft snap --target-arch=arm64 --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap
    at ChildProcess.<anonymous> (/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99:24)
    at ChildProcess.emit (node:events:376:20)
    at maybeClose (node:internal/child_process:1063:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5) {
  cmd: '/snap/bin/snapcraft',
  args: [
    'snap',
    '--target-arch=arm64',
    '--output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap'
  ],
  stdout: '',
  stderr: '',
  code: 2
}
LabhanshAgrawal commented 3 years ago

I have multipass installed already, though haven't done any specific setup if required.

mmaietta commented 3 years ago

In this case, this is the issue:

electron-installer-snap:snapcraft Running '/snap/bin/snapcraft snap --target-arch=arm64 --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap' in /tmp/electron-snap-3555EIoX5MRssVHJ +0ms Ignoring '--target-arch' flag. This flag requires --destructive-mode and is unsupported with Multipass and LXD build providers.

I'm still unable to find how electron-builder compiles the snap though, I don't see a --target-arch arg anywhere in the codebase

Can you apply this patch to your codebase and post the results? app-builder-lib+22.10.5.patch

diff --git a/node_modules/app-builder-lib/out/targets/snap.js b/node_modules/app-builder-lib/out/targets/snap.js
index 3921ea3..4cc7cca 100644
--- a/node_modules/app-builder-lib/out/targets/snap.js
+++ b/node_modules/app-builder-lib/out/targets/snap.js
@@ -263,7 +263,14 @@ class SnapTarget extends _core().Target {

     const stageDir = await (0, _targetUtil().createStageDirPath)(this, packager, arch);
     const snapArch = (0, _builderUtil().toLinuxArchString)(arch, "snap");
-    const args = ["snap", "--app", appOutDir, "--stage", stageDir, "--arch", snapArch, "--output", artifactPath, "--executable", this.packager.executableName];
+    let args = ["snap", "--app", appOutDir, "--stage", stageDir, "--output", artifactPath, "--executable", this.packager.executableName];
+
+    if (snapArch !== process.arch) {
+      args = [...args, "--target-arch", snapArch, '--destructive-mode'];
+    } else {
+      args = [...args, "--arch", snapArch];
+    }
+
     await this.helper.icons;

     if (this.helper.maxIconPath != null) {
LabhanshAgrawal commented 3 years ago

I applied that patch but it wasn't having any effect. I found out that the args are coming from node_modules/electron-installer-snap/src/index.js line 53 I added the destructive-mode argument and reran The error has changed now

  electron-installer-snap:default_args Reading package metadata from /home/labhansh/hyper/dist/linux-arm64-unpacked/resources/app.asar +0ms
  electron-installer-common:desktop Creating desktop file at /tmp/electron-snap-6220rH9uek5za5WQ/snap/gui/hyper.desktop +0ms
  electron-installer-common:template Generating template from /home/labhansh/hyper/node_modules/electron-installer-snap/resources/desktop.ejs +0ms
  electron-installer-common:template Generated template from /home/labhansh/hyper/node_modules/electron-installer-snap/resources/desktop.ejs
  electron-installer-common:template [Desktop Entry]
  electron-installer-common:template Name=Hyper
  electron-installer-common:template Exec=hyper %U
  electron-installer-common:template Icon=${SNAP}/meta/gui/icon.png
  electron-installer-common:template Type=Application
  electron-installer-common:template StartupNotify=true
  electron-installer-common:template 
  electron-installer-common:template  +3ms
  electron-installer-snap:yaml Loading YAML template /home/labhansh/hyper/node_modules/electron-installer-snap/resources/snapcraft.yaml +0ms
  electron-installer-snap:yaml Replacing browser-support plug with browser-sandbox +96ms
The browser-sandbox feature will trigger a manual review in the Snap store.
  electron-installer-snap:yaml Writing new YAML file /tmp/electron-snap-6220rH9uek5za5WQ/snap/snapcraft.yaml +5ms
  electron-installer-snap:snapcraft Running '/snap/bin/snapcraft snap --target-arch=arm64 --destructive-mode --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap' in /tmp/electron-snap-6220rH9uek5za5WQ +0ms
Setting target machine to 'arm64'
Failed to get part information: Cannot find the definition for part 'desktop-gtk3', required by part 'hyper'.
Remote parts are not supported with bases, so make sure that this part is defined in the `snapcraft.yaml`.
/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99
                reject(new ExitCodeError(cmd, args, code, stdout, stderr));
                       ^

ExitCodeError: Command failed with a non-zero return code (2):
/snap/bin/snapcraft snap --target-arch=arm64 --destructive-mode --output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap
    at ChildProcess.<anonymous> (/home/labhansh/hyper/node_modules/@malept/cross-spawn-promise/dist/src/index.js:99:24)
    at ChildProcess.emit (node:events:376:20)
    at maybeClose (node:internal/child_process:1063:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5) {
  cmd: '/snap/bin/snapcraft',
  args: [
    'snap',
    '--target-arch=arm64',
    '--destructive-mode',
    '--output=/home/labhansh/hyper/hyper_3.1.0-canary.4_arm64.snap'
  ],
  stdout: '',
  stderr: '',
  code: 2
}
LabhanshAgrawal commented 3 years ago

Note - The above is not from when I'm building arm64 snap with electron-builder directly. It's from the script in https://github.com/electron-userland/electron-builder/issues/5626#issuecomment-780451154

LabhanshAgrawal commented 3 years ago

With the patch, on running via electron-builder it failed saying that the arguments are unknown. The arguments that are changed on the patch are supplied to app-builder-bin/.../app-builder not directly to snap. I made some other changes to get the destructive-mode flag in there. It still gave me the ⨯ snapcraft does not currently support building arm64 on amd64

This seems to be coming from app-builder-bin instead, from here https://github.com/develar/app-builder/blob/a46528180ad76445639bd25c7e53bc972dd57b50/pkg/package-format/snap/snap.go#L334

mmaietta commented 3 years ago

Nice find! I've not worked with GO before, but it looks like we need to configure the GO runtime? options.arch != runtime.GOARCH

Can you set this env before running electron-builder? GOOS=linux GOARCH=arm64

Ref: https://stackoverflow.com/a/57055919 Valid configurations:

    GOOS - Target Operating System| GOARCH - Target Platform
   -------------------------------|--------------------------
   |           android            |           arm           |  
   |           darwin             |           386           |  
   |           darwin             |           amd64         |    
   |           darwin             |           arm           |  
   |           darwin             |           arm64         |    
   |           dragonfly          |           amd64         |    
   |           freebsd            |           386           |  
   |           freebsd            |           amd64         |    
   |           freebsd            |           arm           |  
   |           linux              |           386           |  
   |           linux              |           amd64         |    
   |           linux              |           arm           |  
   |           linux              |           arm64         |    
   |           linux              |           ppc64         |    
   |           linux              |           ppc64le       |      
   |           linux              |           mips          |   
   |           linux              |           mipsle        |     
   |           linux              |           mips64        |     
   |           linux              |           mips64le      |       
   |           netbsd             |           386           |  
   |           netbsd             |           amd64         |    
   |           netbsd             |           arm           |  
   |           openbsd            |           386           |  
   |           openbsd            |           amd64         |    
   |           openbsd            |           arm           |  
   |           plan9              |           386           |  
   |           plan9              |           amd64         |    
   |           solaris            |           amd64         |    
   |           windows            |           386           |   
   |           windows            |           amd64         |
   ----------------------------------------------------------
LabhanshAgrawal commented 3 years ago

That didn't change the outcome, It's still saying x64. Since it's using prebuilt binaries, I'm guessing the goarch variable is sort of built in. But it all works when targetting armv7l strangely. The arch comparison should fail in that case too.

LabhanshAgrawal commented 3 years ago

Ok in armv7l case there's this --exclude chrome-sandbox --template-url electron4:armhf extra bit at the end of the command maybe we'd need arm64 template or something for this to be supported

mmaietta commented 3 years ago

@LabhanshAgrawal I haven't been able to identify any other sources re: --template-url Have you been able to debug any further?

@develar, I'm not familiar with Golang, would you be able to take a look at this?

LabhanshAgrawal commented 3 years ago

I haven't looked much further yet I just noticed that template thing as I was wondering why it wasn't failing for armv7l and saw that the command getting run is a bit different

axetroy commented 3 years ago

hi! Is there any plan to support mips arch?

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

LabhanshAgrawal commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Yes

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

LabhanshAgrawal commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Yes

myesn commented 2 years ago

Encountered the same error situation, how to solve this problem?

fangpenlin commented 2 years ago

Just encountered the same issue as well

buu700 commented 2 years ago

Any updates? This is a blocker for https://github.com/cyph/cyph/issues/76.

mmaietta commented 2 years ago

Would love to have a community contribution on this. Setting up a local dev environment is fairly straight forward too https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md#to-setup-a-local-dev-environment

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

LabhanshAgrawal commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Yes

mmaietta commented 2 years ago

https://github.com/electron-userland/electron-builder/issues/5626#issuecomment-1031645832

jtbandes commented 1 year ago

I found that a template is not used because this condition explicitly lists x64 and armv7l — that is, there is no template available for arm64 snaps: https://github.com/electron-userland/electron-builder/blob/bb37687540aa254bce6a92a86c56b606cc16f2be/packages/app-builder-lib/src/targets/snap.ts#L56-L60

It looks like an armv7l template was added in https://github.com/electron-userland/electron-builder/commit/6853b37b321bbf34b3bd6c9ec7ff88545b37291f, which might be an example of how to create a template for arm64.

It looks like part of the process was done manually. @develar Would you have any advice on how to do this process for arm64 as well?

lutzroeder commented 1 year ago

@develar @mmaietta looks like these bits are inserted from develar/app-builder/.../snap.go and a template similar to develar/snap-armhf-electron-template would be needed? Do you have any pointers how to proceed?

@mmaietta Arm64 builds for Snap seem to be blocked no matter if the build machine is Arm64 or x64. Can you update the title of this issue to "Snap Arm64 support".