tslab icon indicating copy to clipboard operation
tslab copied to clipboard

Having issues installing on a Macbook Air M1

Open wei3erHase opened this issue 2 years ago • 16 comments

Receiving the following error:

npm ERR! code 1
npm ERR! path /Users/----------/node_modules/zeromq
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! ACTION binding_gyp_libzmq_target_build_libzmq libzmq/lib
npm ERR! Downloading libzmq source...
npm ERR! Building libzmq...
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | arm64
npm ERR! gyp info find Python using Python version 3.9.6 found at "/Users/----------/.pyenv/versions/3.9.6/bin/python3"
npm ERR! gyp info spawn /Users/----------/.pyenv/versions/3.9.6/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/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/----------/node_modules/zeromq/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/----------/Library/Caches/node-gyp/17.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/----------/Library/Caches/node-gyp/17.0.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/----------/Library/Caches/node-gyp/17.0.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/----------/node_modules/zeromq',
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! /Users/----------/node_modules/zeromq/build/Release/../../script/build.sh: line 60: cmake: command not found
npm ERR! make: *** [libzmq/lib] Error 127
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 (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.6.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/17.0.1/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/----------/node_modules/zeromq
npm ERR! gyp ERR! node -v v17.0.1
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/----------/.npm/_logs/2021-10-25T23_23_23_400Z-debug.log

{\__/} ( • . •) / > . < \

wei3erHase avatar Oct 25 '21 23:10 wei3erHase

Had the same issue, it looks like cmake isn't installed: brew install cmake

juaquins avatar Jan 21 '22 17:01 juaquins

@juaquins ser, you just unleashed a very powerful tool {\__/} ( • . •) / > 🏆

wei3erHase avatar Jan 21 '22 17:01 wei3erHase

Had the same issue, it looks like cmake isn't installed: brew install cmake

This guy, my hero ^^

RyanGuild avatar Feb 02 '22 19:02 RyanGuild

Also brew install libsodium.

tg44 avatar Jan 13 '23 09:01 tg44

brew install pkg-config libsodium cmake zeromq got me through yarn install, but now I'm getting a runtime error:

[I 00:10:50.338 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
dyld[50614]: missing symbol called

Is tslab expected to work on m1?

vanjaoljaca avatar Feb 12 '23 16:02 vanjaoljaca

I don't know, I let it go at some point and started prototyping in a single ts file with ts-node...

tg44 avatar Feb 13 '23 15:02 tg44

i can verify it works, but i couldn't replicate it if i had to reinstall, i believe brew install cmake and then run tslab install and follow the readme should do the work, is very experimental imo, VSCode works better than Jupyter Lab (but also needs tslab interpreter)

wei3erHase avatar Feb 14 '23 10:02 wei3erHase

We have a docker image that has tslab installed (based off of the one from deepnote) and it works everywhere except on a couple of M1 laptops we have. Does anybody know why it wouldn't work even if it's running on a container? The kernels are even listed on jupyter lab, but when choosing TS/JS it just hangs when connecting to the kernel and ends up saying unknown kernel.

aecorredor avatar Feb 17 '23 18:02 aecorredor

Have u tried the above instructions? For me no need to do a docker container, actually even vs code jupyter environment loads it.

wei3erHase avatar Feb 18 '23 16:02 wei3erHase

Weirdly enough, npm -g doesn't work for me (after all the brew install commands from above) but pnpm does

dbuezas avatar Aug 24 '23 20:08 dbuezas

hmmm is very unstable tech, weirdly enough is one of those things that work, until they don't and they start to work again with no explanation at all. should this tech have more development and support and could be a very powerful toolset. i recommend also using VSCode notebook support, but the TS features are very limited there.

wei3erHase avatar Aug 24 '23 20:08 wei3erHase

brew install pkg-config libsodium cmake zeromq got me through yarn install, but now I'm getting a runtime error:

[I 00:10:50.338 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
dyld[50614]: missing symbol called

Is tslab expected to work on m1?

Were you ever able to solve this runtime issue? I am experiencing it now.

astears avatar Sep 09 '23 23:09 astears

Hmmm doesn't ring a bell for me, sorry pal.

wei3erHase avatar Sep 10 '23 19:09 wei3erHase

Were you ever able to solve this runtime issue? I am experiencing it now.

@astears Almost certainly you are building it for x86 instead of arm.

You can test this by simply running:

node
...
require('zeromq')

If you get the error, you've built it for the wrong architecture.

When you watch the build you will see something like this:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64 <---- Correct

If you use an incorrect arch command, or an ancient version of node, you will see:

> [email protected] install /Users/douglas.linder/dev/work-snippets/notebooks/tools/zeromq.js
> (shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true node-gyp-build

No native build was found for platform=darwin arch=x64 runtime=node abi=83 uv=1 libc=glibc node=14.16.1 
^^^^^ <----- using x64 architecture because node 14 is so old. 

Don't do that.

If you're installing sodium with brew, you're installed the arm version; you can't do a x86_64 build with an arm dependency; that's why this error occurs.

At any rate, if you still can't fix it, the problem has nothing to do with tslab; see this thread in the zeromq repo; it's an upstream issue.

If you can't get zeromq working, tslab won't ever work.

...

The most common reason this happens is using node 14 or something older.

If you're not already, try node 18.

If that doesn't help, it's because of the issues in zeromq. :/

(The second, imo, reason people struggle to get tslab working is because they failed to install it globally; you cannot run the tslab kernel if it is not globally installed, because the kernel execution:

tools % jupyter kernelspec list
Available kernels:
  python3    /opt/homebrew/Caskroom/miniconda/base/envs/notebooks/share/jupyter/kernels/python3
  jslab      ~/Library/Jupyter/kernels/jslab
  tslab      ~/Library/Jupyter/kernels/tslab

tools % cat ~/Library/Jupyter/kernels/tslab/kernel.json
{"argv": ["tslab", "kernel", "--config-path", "{connection_file}"], "display_name": "TypeScript", "language": "typescript"}%

^ Executes the global tslab executable when it starts.

If you install tslab locally you have to patch this kernel path to the local node_modules /.bin folder.)

douglas-linder-hireup avatar Sep 14 '23 09:09 douglas-linder-hireup

same issue with Mac M2

Update: install cmake is work for me.

zthxxx avatar Oct 26 '23 03:10 zthxxx

Were you ever able to solve this runtime issue? I am experiencing it now.

I'm using it in an m1. Installing it with npn didn't work, but pnpm did.

dbuezas avatar Oct 26 '23 03:10 dbuezas