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

Unable to npm i with recent apidom top-level change #625

Closed
tim-lai opened this issue Sep 17, 2021 · 7 comments
Closed

Unable to npm i with recent apidom top-level change #625

tim-lai opened this issue Sep 17, 2021 · 7 comments
Assignees
Labels
ApiDOM bug Something isn't working

Comments

@tim-lai
Copy link
Contributor

tim-lai commented Sep 17, 2021

ref #609

I'm having problems again with tree-sitter (again). Inside /apidom submodule, npm i fails.

  • I've git submodule update --recursive --remote
  • I've removed node_modules in both swagger-ide and swagger-ide/apidom directories.
  • I also changed my remote origin
  • node is v16.8.
  • can npm i from project root

Any other suggestions?

npm ERR! path /Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/tree-sitter
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! CC(target) Release/obj.target/tree_sitter/vendor/tree-sitter/lib/src/lib.o
npm ERR!   LIBTOOL-STATIC Release/tree_sitter.a
npm ERR!   CXX(target) Release/obj.target/tree_sitter_runtime_binding/src/binding.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.2.0
npm ERR! gyp info using node@16.8.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.2 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/Users/timothy.lai/Repos/apidom-editor/apidom/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/timothy.lai/Repos/apidom-editor/apidom/node_modules/tree-sitter/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/timothy.lai/Library/Caches/node-gyp/16.8.0/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/timothy.lai/Library/Caches/node-gyp/16.8.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/timothy.lai/Library/Caches/node-gyp/16.8.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/tree-sitter',
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/binding.cc:1:
npm ERR! In file included from /Users/timothy.lai/Library/Caches/node-gyp/16.8.0/include/node/node.h:63:
npm ERR! In file included from /Users/timothy.lai/Library/Caches/node-gyp/16.8.0/include/node/v8.h:30:
npm ERR! /Users/timothy.lai/Library/Caches/node-gyp/16.8.0/include/node/v8-internal.h:488:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
npm ERR!             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
npm ERR!                                 ~~~~~^~~~~~~~~~~
npm ERR!                                      remove_cv
npm ERR! /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:697:50: note: 'remove_cv' declared here
npm ERR! template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
npm ERR!                                                  ^
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/tree_sitter_runtime_binding/src/binding.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/timothy.lai/Repos/apidom-editor/apidom/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/Users/timothy.lai/.nvm/versions/node/v16.8.0/bin/node" "/Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/timothy.lai/Repos/apidom-editor/apidom/node_modules/tree-sitter
npm ERR! gyp ERR! node -v v16.8.0
npm ERR! gyp ERR! node-gyp -v v8.2.0
npm ERR! gyp ERR! not ok

@tim-lai tim-lai added ApiDOM bug Something isn't working labels Sep 17, 2021
@tim-lai
Copy link
Contributor Author

tim-lai commented Sep 17, 2021

@frantuma When you did the last update for submodule, did you also need to commit changes to swagger-ide/apidom? Because I can still run both of these commands:

➜  apidom-editor git:(main) ✗ git submodule update
Submodule path 'apidom': checked out '71b5cba698c3a5f67ce8527e2c3f2d2ef12eecab'
➜  apidom-editor git:(chore/apidom-top-level) ✗ git submodule update --recursive --remote
Submodule path 'apidom': checked out '0fcd7e4be49e77d2b075ee5f49d3e51493fc9237'

Running the latter results in git change, so wanted to confirm.

The first one, has been my working "branch", e.g. prior to the apidom top-level change today.

@char0n
Copy link
Member

char0n commented Sep 20, 2021

Looks like a local problem of some sort specific to your OS. You're using the correct Node.js version, node-gyp and npm. My version of Python is 3.8.10, I see that yours is 3.8.2 (but I doubt it makes any difference). The problem must be somewhere else. I've just cloned this repo and have not problem installing it locally. CI is passing as well on latest Ubuntu versions.

These are the things I can suggest:

Clear the npm cache

run the npm cache clean --force

Reinstall Node.js 16.8

Purge it completely and reinstall it.

Install tree-sitter in tmp dir

Try to install just tree-sitter@0.19.0 to your tmp directory. Make sure you use Node.js 16.8

 $ cd /tmp
 $ npm i tree-sitter@0.19.0

Does this work?

@frantuma
Copy link
Member

@tim-lai can you check what suggested by @char0n above?

@tim-lai
Copy link
Contributor Author

tim-lai commented Sep 22, 2021

@char0n @frantuma Here's the latest update... the 3 suggestions do not work for my local system. I found these:

tree-sitter/tree-sitter#1078

...which leads to the following:
tree-sitter/node-tree-sitter#82

and a related merged PR:
tree-sitter/node-tree-sitter#92

but an unmerged PR that looks to do the same as merged PR here:
tree-sitter/node-tree-sitter#83

and a cited ref, though the last comment doesn't work for me either (with npm) , yarn install -std=c++17:
nodejs/node#38367

For tree-sitter the merged PR that might resolve this was merged 7 days ago, so maybe soon we'll get a new release.

additional notes...

  • re: install to /tmp... I can npm i tree-sitter if using Node@14, but not Node@16.8/16.9/16.10
  • I'm on a Mac, was using Catalina, now using Big Sur, and was ready to blame XCode, but alas, did not magically resolve

@char0n
Copy link
Member

char0n commented Sep 23, 2021

As we suspected, MacOS related issue. We cannot rely on tree-sitter release cadence here to fix it. If it works for you on Node@14, just use Node@14. In order to successfully use earlier versions of Node.js like, Node@14 you have to do the following step after installing it:

 $ npm install -g npm
 $ npm --version 

Make sure than npm --version reports >= 7. At this point we don't rely on any specific feature from Node.js 16 (except for npm@7), so if problems like this arise we have an option to use older Node.js version and update npm manually to newest npm version. I'm 99% sure, this workaround will work for you, given you're able install with Node.js=14.

@tim-lai
Copy link
Contributor Author

tim-lai commented Sep 23, 2021

@char0n @frantuma Using npm@7 globally worked for me. With npm@7 and node@14, both npm i and npm run build can run successfully on Mac. I'll update the README.md in swagger-ide

@char0n
Copy link
Member

char0n commented Sep 24, 2021

@tim-lai good, glad it's resolved for you for now

I'll update the README.md in swagger-ide

Not sure if it's needed, we want to stay on minimal Node.js version of 16.8. If you mean adding note for MacOS local dev env sure, make sense untill tree-sitter flag problem is fixed.

@char0n char0n closed this as completed Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ApiDOM bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants