oxen-io / session-desktop

Session Desktop - Onion routing based messenger
https://getsession.org
GNU General Public License v3.0
1.43k stars 186 forks source link

[BUG] yarn build-everything does not work with Mac M1 and rosetta #3010

Closed VityaSchel closed 5 months ago

VityaSchel commented 5 months ago

Code of conduct

Self-training on how to write a bug report

Is there an existing issue for this?

Current Behavior

I tried to build session on my mac with arch -x86_64 zsh. I ended up installing correct versions of node (process.arch shows x64), yarn (running with sudo because otherwise it gives me segmentation faults) and built session with sudo yarn build-everything however when I try to sudo yarn start-dev or sudo yarn start-prod it throws ERR_DLOPEN_FAILED:

yarn run v1.22.21
$ cross-env NODE_ENV=development NODE_APP_INSTANCE=devprod$MULTI electron .
Set Windows Application User Model ID (AUMID) { appUserModelId: 'com.loki-project.messenger-desktop' }
WARNING: NODE_APP_INSTANCE value of 'devprod' did not match any instance config file names.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
NODE_ENV development
NODE_APP_INSTANCE devprod
NODE_CONFIG_DIR /Users/hloth/Documents/session-desktop/config
NODE_CONFIG {}
userData: /var/root/Library/Application Support/Session-development-devprod
config/get: Did not find user config file, cache is now empty object
App threw an error during load
Error: dlopen(/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node, 0x0001): tried: '/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (no such file), '/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1869)
    at Module._extensions..node (node:internal/modules/cjs/loader:1354:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1869)
    at Module.load (node:internal/modules/cjs/loader:1124:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Module.require (node:internal/modules/cjs/loader:1148:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/index.js:1:30)
    at Module._compile (node:internal/modules/cjs/loader:1269:14)
Unhandled Error: Error: dlopen(/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node, 0x0001): tried: '/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (no such file), '/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/build/Release/libsession_util_nodejs.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1869)
    at Module._extensions..node (node:internal/modules/cjs/loader:1354:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1869)
    at Module.load (node:internal/modules/cjs/loader:1124:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Module.require (node:internal/modules/cjs/loader:1148:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/hloth/Documents/session-desktop/node_modules/libsession_util_nodejs/index.js:1:30)
    at Module._compile (node:internal/modules/cjs/loader:1269:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Expected Behavior

I suppose it's an issue with libsession-utils native bindings but I'm not sure how to rebuilt them with build-everything command. It should've worked fine if other things supported arm architecture like node-gyp but they're not so I'm forced to use rosetta

Steps To Reproduce

  1. Clone repo on Mac M1
  2. Run arch -x86_64 zsh
  3. Run nvm install v18.15.0 && nvm use
  4. Run sudo yarn install --frozen-lockfile
  5. Run sudo yarn build-everything
  6. Run sudo yarn start-prod

Desktop Version

Latest commit in clearnet branch

Anything else?

No response

VityaSchel commented 5 months ago

Ok it resolved with simply not enabling rosetta and going with arm lol

yougotwill commented 5 months ago

Glad you sorted it out.