Open trevor-e opened 5 months ago
I narrowed it down to the custom actions being done in binding.gyp
:
"actions": [
{
"action_name": "wait_for_tree_sitter",
"action": ["node", "scripts/wait-for-tree-sitter.js"],
"inputs": [],
"outputs": ["node_modules/tree-sitter-cli"]
},
{
"action_name": "generate_header_files",
"inputs": [
"grammar.js",
"node_modules/tree-sitter-cli"
],
"outputs": [
"src/grammar.json",
"src/node-types.json",
"src/parser.c",
"src/tree_sitter",
],
"action": ["tree-sitter", "generate", "--no-bindings"],
}
]
I see the node-gyp build step produces a Makefile that tries to call tree-sitter-cli
and fails, which is what the error message in the OP is referring to. I tried a few things but couldn't figure out a way to fix this using the custom GYP setup going on in this repo, as a workaround I'm using a fork in https://github.com/trevor-e/tree-sitter-swift/pull/3 which reverts gitignoring some of the generated files. I see in the README that you won't accept PRs that check in the generated files so this seems unlikely to get merged.
This is very strange. I added that action because without it, npm install
was flaky; the core issue is that tree-sitter-cli
downloads its binary asynchronously at install time. But it seems like something doesn't work quite right...
I wonder if I should just switch NPM publishing over to the with-generated-files
branch.
Yea I think switching to the 'with-generated-files' branch, at least for publishing, is probably the easiest. If you release 0.5.0 on GitHub I'm happy to test that out before publishing it to npm.
ok, just tagged the 0.5.0 release and updated the generated files branch. Let me know how your testing goes. I added a binding.gyp
to that branch that doesn't try to generate files (since it doesn't need to :stuck_out_tongue:). Let me know how your testing goes and if there are any other files that need to be added.
Sorry for the delay! I tried the with-generated-files
branch and I'm getting a new error:
npm error ../bindings/node/binding.cc:3:10: fatal error: 'nan.h' file not found
npm error #include "nan.h"
The binding.cc
file looks stale since it's still referencing nan.h
and not napi.h
. I checked out the branch locally, ran tree-sitter generate
, and see there are a bunch of changes that weren't committed. I think the write-generated-grammar.sh
script might be out of date and needs to add some extra files like you said.
I tried switching my local forked install back to the upstream 0.5.0 version you just released (thanks btw!), and now I'm getting this error:
Oddly this doesn't happen when I install the package locally with something like
"file:../
which I see is what thetest-npm-package
project is doing. Running both theinstall
andpostinstall
NPM scripts work for me too.