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

Issue installing tree-sitter with pnpm #123

Open
kevinkeckeis opened this issue Feb 18, 2023 · 5 comments
Open

Issue installing tree-sitter with pnpm #123

kevinkeckeis opened this issue Feb 18, 2023 · 5 comments

Comments

@kevinkeckeis
Copy link

Issue installing tree-sitter with pnpm

When trying to install tree-sitter with pnpm install, the installation fails with an "ELIFECYCLE Command failed" error. Upon investigating, it appears that the installation script checks for a pre-built binary, which is not available for Linux systems. As a result, the script tries to build tree-sitter using node-gyp, which is not included as a dependency and is not installed on the system, causing the installation to fail.

The following error message is displayed when running pnpm install inside the node_modules/tree-sitter folder:

prebuild-install WARN install No prebuilt binaries found (target=18.14.0 runtime=node arch=x64 libc= platform=linux)
sh: 1: node-gyp: not found

I am not experienced with build systems, and was surprised that npm attempted to run the command and even fetch and install node-gyp if it was detected. I expected the installation script to either run without issues or return a proper error message indicating the missing dependency.

Possible Solutions/Workarounds:

  • Adding node-gyp as a dependency resolved the issue, but I am unsure if this is the desired solution for the maintainer.
  • Installing node-gyp globally also worked for me.

Versions:

  • Pop!_OS 22.04 LTS
  • NodeJs 18.14.0 (LTS)
  • pnpm 7.27.1
  • tree-sitter 0.20.1
@sogaiu
Copy link

sogaiu commented Feb 19, 2023

After writing the following I got the sense that cloning this repository and trying to use tree-sitter from within it isn't really an intended scenario. I'll leave the rest of the post here though as it may have some clues regarding various build / installation issues.

Old content follows.


I don't use pnpm but I just tested some installation-like steps using 16f7319 (note that's the latest commit on the "default" branch here as of this writing) with a number of Node.js / npm versions using nvm.

What I found is that success varied, depending on at least a few things.

First, I used --recursive when cloning the repository, so just git clone https://github.com/tree-sitter/node-tree-sitter didn't lead to successful builds [1].

Then, for the following versions of Node.js, npm install completes successfully:

  • v12.22.12
  • v14.21.1
  • v16.19.0

npx tree-sitter dump-languages didn't work for v16.19.0 (though it did work for the other 2 versions), so although it appears building was successful for that version, that doesn't by itself seem sufficient for use (at least of the cli).

npm install didn't successfully complete here for the following versions:

  • v18.14.1
  • v19.6.1

As I understand it, npm is capable of using node-gyp (one it depends on / is bundled with) to handle the case of binding.gyp being in a project's repository -- i.e. this is without a project specifically having node-gyp as a dependency or devDependency. I may be wrong about this though -- it doesn't seem so straight-forward to get answers to these sorts of things unfortunately.

As some evidence in favor of the above idea though, according to this nicely buried piece of documentation:

If there is a binding.gyp file in the root of your package and you haven't defined your own install or preinstall scripts, npm will default the install command to compile using node-gyp.

That's for v6 of npm, but looking at the corresponding page for more recent versions one can see similar text.

Perhaps the code in 16f7319 of node-tree-sitter doesn't play so well with more recent versions of Node.js / npm.


[1] IIUC, there is a git submodule involved so that needs to be attended to appropriately I guess (possibly using git submodule subcommands like init and update if --recursive or other is not using during a clone).

@davidluhr
Copy link

I'm experiencing the same issue when trying npm install tree-sitter, both in Windows Subsystem for Linux 2 (which uses Ubuntu), and in MacOS.

WSL2 (Ubuntu) output:
prebuild-install WARN install No prebuilt binaries found (target=19.7.0 runtime=node arch=x64 libc= platform=linux)

MacOS output:
prebuild-install WARN install No prebuilt binaries found (target=19.7.0 runtime=node arch=x64 libc= platform=darwin)

I tried with older versions of Node and had the same issue. Not sure how to proceed.

@sogaiu
Copy link

sogaiu commented Mar 3, 2023

I'm not sure I parse the errors you posted correctly, but the sense I get is that those are for node 19.7.0, which I didn't have any luck with (along with the 18 series).

It seems though that some people have had success with 18 (though not 19). Here is another report of some success with 18.

If it's practical for you to try with node 12.x or 14.y may be it's worth it? Or may be you tried and got errors? If so, would you mind sharing them?

It was unclear to me whether any of the 16 series would work either based on my own testing, but there is also a report here of lack of success on that front -- though at the end it seems another person may have resolved things.

@sogaiu
Copy link

sogaiu commented Mar 7, 2023

This comment might be of interest if trying to get things working with Node.js 19.x.

@verhovsky
Copy link
Collaborator

pnpm/pnpm#4347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants