pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.12k stars 130 forks source link

node-gyp-build / zadeh issue on arm64 macOS #580

Closed gnmerritt closed 1 year ago

gnmerritt commented 1 year ago

Thanks in advance for your bug report!

What happened?

The package atom-ide-rust is broken, trying and failing to find a native prebuild for zadeh. I'm reporting this here because it looks like zadeh is widely used so it may be affecting many more packages for folks on darwin-arm64. This all worked fine with identical packages versions under Atom, so I think there may be a Pulsar specific bug or at least a recent regression.

I was able to get past the initial package load failure (stack trace attached below) and cause a different editor crash with the following:

# there is no darwin-arm64 prebuild shipped with zadeh:
ls ~/.pulsar/packages/ide-rust/node_modules/zadeh/prebuilds/
  darwin-x64    linux-x64   win32-ia32  win32-x64

git clone https://github.com/atom-community/zadeh.git
cd zadeh

# need to stop the builder from hitting https://atom.io/download/electron/v6.0.0/node-v6.0.0-headers.tar.gz
# which now perma-redirects to the sunset blog post
wget https://nodejs.org/dist/v14.16.0/node-v14.16.0-headers.tar.gz
npm config set tarball node-v14.16.0-headers.tar.gz

npm install
cp -a prebuilds/darwin-arm64 ~/.pulsar/packages/atom-ide-outline/node_modules/zadeh/prebuilds/
cp -a prebuilds/darwin-arm64 ~/.pulsar/packages/atom-ide-outline/node_modules/zadeh/prebuilds/

The ide-rust package loads with the above (prompts me to update my rustc version, installs its dependencies, etc) but when I open a rust file I get an "editor has crashed" dialog and these in the console:

Uncaught (in promise) Error: Dependency#0 for ide-rust is invalid
    at C (/Users/nathan/.pulsar/packages/ide-rust/node_modules/atom-package-deps/lib/index.js:1)
    at /Users/nathan/.pulsar/packages/ide-rust/node_modules/atom-package-deps/lib/index.js:1
    at Array.forEach (<anonymous>)
    at D (/Users/nathan/.pulsar/packages/ide-rust/node_modules/atom-package-deps/lib/index.js:1)
    at Object.exports.install (/Users/nathan/.pulsar/packages/ide-rust/node_modules/atom-package-deps/lib/index.js:1)
    at RustLanguageClient.activate (/Users/nathan/.pulsar/packages/ide-rust/lib/index.js:428)
...
Uncaught (in promise) Error: Dependency#0 for atom-ide-definitions is invalid
    at invariant (VM2151 index.js:553)
    at VM2151 index.js:571
    at Array.forEach (<anonymous>)
    at getDependencies$2 (VM2151 index.js:561)
    at Object.install (VM2151 index.js:912)

So I'm guessing it's something like the following:

There's no prebuild for darwin-arm64 shipped with zadeh Something about the build/install process (likely at least fetching the node headers) is silently failing The package then fails to load When I build the zadeh out-of-band and copy in the prebuild I probably got a version wrong or something, so my prebuild doesn't work either.

Pulsar version

1.105.0 arm64

Which OS does this happen on?

🍎 macOS

OS details

macOS 13.4

Which CPU architecture are you running this on?

Apple M1/M2

What steps are needed to reproduce this?

  1. Open Pulsar with ide-rust enabled
  2. Open a rust file, ide-rust will crash failing to load zadeh

Additional Information:

Stack Trace

Failed to load the ide-rust package

At No native build was found for platform=darwin arch=arm64 runtime=electron abi=87 uv=1 armv=8 libc=glibc node=14.16.0 electron=12.2.3
    loaded from: /Users/nathan/.pulsar/packages/ide-rust/node_modules/zadeh

Error: No native build was found for platform=darwin arch=arm64 runtime=electron abi=87 uv=1 armv=8 libc=glibc node=14.16.0 electron=12.2.3
    loaded from: /Users/nathan/.pulsar/packages/ide-rust/node_modules/zadeh

    at Function.load.resolve.load.path (/packages/ide-rust/node_modules/node-gyp-build/node-gyp-build.js:60:9)
    at load (/packages/ide-rust/node_modules/node-gyp-build/node-gyp-build.js:22:30)
    at /packages/ide-rust/node_modules/zadeh/index.js:1:2743)
    at /packages/ide-rust/node_modules/zadeh/index.js:4:3)
    at Module._compile (/app.asar/src/native-compile-cache.js:120:30)
    at /app.asar/src/compile-cache.js:252:23)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Function.o._load (electron/js2c/renderer_init.js:33:379)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (/app.asar/src/native-compile-cache.js:67:27)
    at /packages/ide-rust/node_modules/atom-languageclient/build/lib/adapters/autocomplete-adapter.js:15:17)
    at /packages/ide-rust/node_modules/atom-languageclient/build/lib/adapters/autocomplete-adapter.js:441:3)
    at Module._compile (/app.asar/src/native-compile-cache.js:120:30)
    at /app.asar/src/compile-cache.js:252:23)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Function.o._load (electron/js2c/renderer_init.js:33:379)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (/app.asar/src/native-compile-cache.js:67:27)
    at /packages/ide-rust/node_modules/atom-languageclient/build/lib/auto-languageclient.js:19:32)
    at /packages/ide-rust/node_modules/atom-languageclient/build/lib/auto-languageclient.js:952:3)
    at Module._compile (/app.asar/src/native-compile-cache.js:120:30)
    at /app.asar/src/compile-cache.js:252:23)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Function.o._load (electron/js2c/renderer_init.js:33:379)
gnmerritt commented 1 year ago

Okay, I'm able to resolve this error for real for https://github.com/rust-lang/atom-ide-rust with the following:

ppm uninstall ide-rust
ppm install ide-rust
cd ~/.pulsar/packages/ide-rust/node_modules/zadeh/
node-gyp rebuild

When I do the same process for https://github.com/atom-community/atom-ide-outline I still get an editor crash:

2023-06-08 11:02:43.722 Electron[45495:171807] +[CATransaction synchronize] called within transaction
dyld[45498]: missing symbol called
Renderer process crashed - see https://www.electronjs.org/docs/tutorial/application-debugging for potential debugging information.

full macOs crash file here: https://www.dropbox.com/s/4lwl4dzxdfir0cs/zadeh-crash%20-%20Electron%20Helper%20%28Renderer%29-2023-06-08-110254.ips?dl=0

Shouldn't something similar to me issuing node-gyp rebuild happen automatically on package install? I'm still not sure I understand why all this worked fine with Atom + identical sources but isn't working for me now with Pulsar.

gnmerritt commented 1 year ago

I've also filed an issue on zadeh itself to try and see if I can get the missing prebuilds added: https://github.com/atom-community/zadeh/issues/103

gnmerritt commented 1 year ago

ahh ok, so my Atom version is 1.60.0 intel x64. I've confirmed that using an intel build of Pulsar on my M1 mac fixes this issue, so I think that resolves this being Pulsar's problem to try and work around rather than the extensions themselves.