Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal not working on M1 #2161

Closed
olensmar opened this issue Aug 1, 2022 · 5 comments
Closed

Terminal not working on M1 #2161

olensmar opened this issue Aug 1, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@olensmar
Copy link
Member

olensmar commented Aug 1, 2022

I get the following on terminal initialization...

 [2022-08-01 12:45:58.506] [browser] [error] innerError Error: Cannot find module '../build/Debug/pty.node'
[2] Require stack:
[2] - /Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/lib/unixTerminal.js
[2] - /Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/lib/index.js
[2] - /Users/olensmar/WebstormProjects/monokle/build/electron/app/ipc/ipcListeners.js
[2] - /Users/olensmar/WebstormProjects/monokle/build/electron/app/index.js
[2] - /Users/olensmar/WebstormProjects/monokle/build/electron/main.js
[2] - /Users/olensmar/WebstormProjects/monokle/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js
[2] - 
[2]     at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
[2]     at n._resolveFilename (node:electron/js2c/browser_init:245:1105)
[2]     at Module._resolveFilename (/Users/olensmar/WebstormProjects/monokle/node_modules/module-alias/index.js:49:29)
[2]     at Module._load (node:internal/modules/cjs/loader:785:27)
[2]     at c._load (node:electron/js2c/asar_bundle:5:13343)
[2]     at Module.require (node:internal/modules/cjs/loader:1012:19)
[2]     at require (node:internal/modules/cjs/helpers:102:18)
[2]     at Object.<anonymous> (/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/lib/unixTerminal.js:30:15)
[2]     at Module._compile (node:internal/modules/cjs/loader:1118:14)
[2]     at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
[2] [2022-08-01 12:45:58.507] [browser] [error] (node:24798) UnhandledPromiseRejectionWarning: Error: dlopen(/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/build/Release/pty.node, 0x0001): tried: '/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/build/Release/pty.node' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
[2]     at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
[2]     at Module._extensions..node (node:internal/modules/cjs/loader:1203:18)
[2]     at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
[2]     at Module.load (node:internal/modules/cjs/loader:988:32)
[2]     at Module._load (node:internal/modules/cjs/loader:829:12)
[2]     at c._load (node:electron/js2c/asar_bundle:5:13343)
[2]     at Module.require (node:internal/modules/cjs/loader:1012:19)
[2]     at require (node:internal/modules/cjs/helpers:102:18)
[2]     at Object.<anonymous> (/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/lib/unixTerminal.js:26:11)
[2]     at Module._compile (node:internal/modules/cjs/loader:1118:14)
[2] [2022-08-01 12:45:58.507] [browser] [error] (node:24798) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which w

could electron-builder be building wrong binary during npm-install?! (would expect arch to be arm64 or something..)

 npm install

> monokle@1.9.1 postinstall
> patch-package && electron-builder install-app-deps

patch-package 6.4.7
Applying patches...
react-reflex@4.0.9 ✔
  • electron-builder  version=23.3.3
  • loaded configuration  file=package.json ("build" field)
  • rebuilding native dependencies  dependencies=node-pty@0.10.1 platform=darwin arch=x64

> monokle@1.9.1 prepare
> husky install

husky - Git hooks installed

up to date in 8s

@olensmar
Copy link
Member Author

olensmar commented Aug 3, 2022

Update: I tried creating a production build and the terminal works fine with the installed version of Monokle..!? Could it be something with my local environment!?

@olensmar
Copy link
Member Author

olensmar commented Aug 5, 2022

I've tried upgrading to electron 20.0.X in line with this fix - electron/electron#35160 - but that results in errors when running a clean npm install:

  • rebuilding native dependencies  dependencies=node-pty@0.10.1 platform=darwin arch=x64
  ⨯ cannot execute  cause=exit status 1
                    errorOut=npm ERR! code 1
    npm ERR! path /Users/olensmar/WebstormProjects/monokle/node_modules/node-pty
    npm ERR! command failed
    npm ERR! command sh -c node scripts/install.js
    npm ERR! CXX(target) Release/obj.target/pty/src/unix/pty.o
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.4.1
    npm ERR! gyp info using node@16.16.0 | darwin | x64
    npm ERR! gyp info find Python using Python version 3.7.9 found at "/usr/local/bin/python3"
    npm ERR! gyp info spawn /usr/local/bin/python3
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/Users/olensmar/WebstormProjects/monokle/node_modules/node-gyp/gyp/gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'make',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/olensmar/WebstormProjects/monokle/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/olensmar/.electron-gyp/20.0.1/include/node/common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/olensmar/.electron-gyp/20.0.1',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/olensmar/WebstormProjects/monokle/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/olensmar/.electron-gyp/20.0.1/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/olensmar/WebstormProjects/monokle/node_modules/node-pty',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp info spawn make
    npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! In file included from ../../nan/nan.h:60:
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/node.h:27:2: error: "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly."
    npm ERR! #error "It looks like you are building this native module without using the right config.gypi.  This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly."
    npm ERR!  ^
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! In file included from ../../nan/nan.h:60:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/node.h:69:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8.h:24:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-object.h:9:
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-maybe.h:106:45: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
    npm ERR!   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
    npm ERR!                                        ~~~~~^~~~~~~~~~~~~~~~~~~~~
    npm ERR!                                             is_lvalue_reference
    npm ERR! /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here
    npm ERR! struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
    npm ERR!                             ^
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! In file included from ../../nan/nan.h:60:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/node.h:69:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8.h:24:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-object.h:9:
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-maybe.h:106:69: error: expected '(' for function-style cast or type construction
    npm ERR!   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
    npm ERR!                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-maybe.h:123:43: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
    npm ERR! template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
    npm ERR!                                      ~~~~~^~~~~~~~~~~~~~~~~~~~~
    npm ERR!                                           is_lvalue_reference
    npm ERR! /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:910:29: note: 'is_lvalue_reference' declared here
    npm ERR! struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { };
    npm ERR!                             ^
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! In file included from ../../nan/nan.h:60:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/node.h:69:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8.h:24:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-array-buffer.h:13:
    npm ERR! In file included from /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-object.h:9:
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-maybe.h:123:67: error: expected '(' for function-style cast or type construction
    npm ERR! template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
    npm ERR!                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! In file included from ../../nan/nan.h:180:
    npm ERR! ../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
    npm ERR! typedef v8::Local<v8::AccessorSignature> Sig;
    npm ERR!                   ~~~~^
    npm ERR! In file included from ../src/unix/pty.cc:20:
    npm ERR! ../../nan/nan.h:2546:8: error: no matching member function for call to 'SetAccessor'
    npm ERR!   tpl->SetAccessor(
    npm ERR!   ~~~~~^~~~~~~~~~~
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-template.h:814:8: note: candidate function not viable: no known conversion from 'imp::Sig' (aka 'int') to 'v8::SideEffectType' for 7th argument
    npm ERR!   void SetAccessor(
    npm ERR!        ^
    npm ERR! /Users/olensmar/.electron-gyp/20.0.1/include/node/v8-template.h:807:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'v8::AccessorGetterCallback' (aka 'void (*)(Local<v8::String>, const PropertyCallbackInfo<v8::Value> &)') for 2nd argument
    npm ERR!   void SetAccessor(
    npm ERR!        ^
    npm ERR! 7 errors generated.
    npm ERR! make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
    npm ERR! gyp ERR! build error 
    npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
    npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/olensmar/WebstormProjects/monokle/node_modules/node-gyp/lib/build.js:194:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    npm ERR! gyp ERR! System Darwin 21.6.0
    npm ERR! gyp ERR! command "/Users/olensmar/.nvm/versions/node/v16.16.0/bin/node" "/Users/olensmar/WebstormProjects/monokle/node_modules/.bin/node-gyp" "rebuild"
    npm ERR! gyp ERR! cwd /Users/olensmar/WebstormProjects/monokle/node_modules/node-pty
    npm ERR! gyp ERR! node -v v16.16.0
    npm ERR! gyp ERR! node-gyp -v v8.4.1
    npm ERR! gyp ERR! not ok
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/olensmar/.npm/_logs/2022-08-05T10_21_45_648Z-debug-0.log
    
                    command=/Users/olensmar/.nvm/versions/node/v16.16.0/bin/node /Users/olensmar/.nvm/versions/node/v16.16.0/lib/node_modules/npm/bin/npm-cli.js rebuild node-pty@0.10.1
                    workingDir=


@olensmar
Copy link
Member Author

I was able to fix this locally by hardcoding the arch for electron-builder in package.json:

"postinstall": "patch-package && electron-builder install-app-deps --arch arm64",

@chargio
Copy link
Contributor

chargio commented Nov 14, 2022

This seems to be working now. Can we close this?

@olensmar
Copy link
Member Author

the fix I did above only works for me locally, it will break the build for non-M1 users so I haven't committed this - but I'm fine closing it..

@chargio chargio closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants