webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.8k stars 161 forks source link

Cannot be installed on linux due to binary dependencies #211

Closed Raynos closed 1 year ago

Raynos commented 1 year ago
$ npm i knip -g
npm ERR! code 1
npm ERR! path /home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild
npm ERR! make: Entering directory '/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash/build'
npm ERR!   CC(target) Release/obj.target/tree_sitter_bash_binding/src/parser.o
npm ERR!   CXX(target) Release/obj.target/tree_sitter_bash_binding/bindings/node/binding.o
npm ERR! make: Leaving directory '/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash/build'
npm ERR! prebuild-install warn install No prebuilt binaries found (target=18.16.1 runtime=node arch=x64 libc= platform=linux)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.16.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/raynos/projects/nvm/versions/node/v18.16.1/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   '/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/raynos/.cache/node-gyp/18.16.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=/home/raynos/.cache/node-gyp/18.16.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/raynos/.cache/node-gyp/18.16.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash',
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/parser.c:1:
npm ERR! ../src/parser.c: In function ‘ts_lex_keywords’:
npm ERR! ../src/tree_sitter/parser.h:135:8: warning: variable ‘eof’ set but not used [-Wunused-but-set-variable]
npm ERR!   135 |   bool eof = false;             \
npm ERR!       |        ^~~
npm ERR! ../src/parser.c:12592:3: note: in expansion of macro ‘START_LEXER’
npm ERR! 12592 |   START_LEXER();
npm ERR!       |   ^~~~~~~~~~~
npm ERR! make: g++-10: No such file or directory
npm ERR! make: *** [tree_sitter_bash_binding.target.mk:122: Release/obj.target/tree_sitter_bash_binding/bindings/node/binding.o] 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 (/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 6.2.6-76060206-generic
npm ERR! gyp ERR! command "/home/raynos/projects/nvm/versions/node/v18.16.1/bin/node" "/home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/raynos/projects/nvm/versions/node/v18.16.1/lib/node_modules/knip/node_modules/tree-sitter-bash
npm ERR! gyp ERR! node -v v18.16.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/raynos/.npm/_logs/2023-08-21T15_46_25_651Z-debug-0.log

The tree sitter bash library does not compile.

webpro commented 1 year ago

Yeah sorry about that. Duplicate of #209, let's track it over there.

Raynos commented 1 year ago

It's clearly not a duplicate because it has nothing to do with missing python and everything to do with the third party dependency not compiling due to a bug in their C++

Raynos commented 1 year ago

It looks like they hard coded g++-10 somewhere

npm ERR! make: g++-10: No such file or directory

And because I don't have g++-10 on my laptop I cannot compile this third party depedency.

Raynos commented 1 year ago

I should probably install 2.19.5 instead because it does not have the broken third party dependency.

webpro commented 1 year ago

I should probably install 2.19.5 instead because it does not have the broken third party dependency.

Yes.

I'm thinking about downgrading tree-sitter-bash to v0.19.0 but that will likely not help you here either.

webpro commented 1 year ago

You might want to try v2.19.8 with the downgraded 3rd party dep.

sbason commented 1 year ago

We have this same issue and v2.19.8 does not fix it I'm afraid. The newest version that works is v2.19.5.

webpro commented 1 year ago

It's clearly not a duplicate because it has nothing to do with missing python and everything to do with the third party dependency not compiling due to a bug in their C++

Sorry about that, read and assumed too fast that "No prebuilt binaries found" would essentially be the same issue (since the binaries are missing):

npm ERR! prebuild-install warn install No prebuilt binaries found (target=18.16.1 runtime=node arch=x64 libc= platform=linux)

tree-sitter-bash v0.19.0 has this list of binaries: https://github.com/tree-sitter/tree-sitter-bash/releases/tag/v0.19.0. Not sure what's missing that would match your environment(s)?

Wanted to get rid of an ancient dependency. Also see #72. The tree-sitter replacement works slightly better than bash-parser, so I don't fancy reverting, which would be a breaking change again.

Raynos commented 1 year ago

None of those prebuilt binaries have anything to do with prebuild-install ( https://github.com/tree-sitter/tree-sitter-bash/blob/master/bindings/node/index.js ).

If you look at https://www.npmjs.com/package/leveldown?activeTab=code it has the binaries in the npm package.

If you look at https://www.npmjs.com/package/tree-sitter-bash?activeTab=code you will see zero binaries in the npm tarball.

The package author of tree-sitter-bash has to change their npm publish strategy ( see https://github.com/Level/leveldown/blob/master/.github/workflows/release.yml as reference )

webpro commented 1 year ago

Guess this wasn't the right time for tree-sitter yet. Reverted to bash-parser in v2.19.11.

Thanks for all the info, I will look into it and pass it through.

webpro commented 1 year ago

None of those prebuilt binaries have anything to do with prebuild-install ( https://github.com/tree-sitter/tree-sitter-bash/blob/master/bindings/node/index.js ).

prebuild-install uses the prebuilt binaries in the GitHub Release by default (the script you link then uses the GitHub Release asset fetched through prebuild-install).

With linking to https://github.com/tree-sitter/tree-sitter-bash/issues/188 I'm going to close this issue.

Tips & tricks still most welcome, either for preventing similar issues in the future or for alternatives.