tree-sitter / workflows

Reusable workflows for tree-sitter parsers
14 stars 8 forks source link

npm publish fails (g++: error: unrecognized command line option ‘-std=gnu++20’; did you mean ‘-std=gnu++2a’?) #16

Open olehermanse opened 1 week ago

olehermanse commented 1 week ago

Problem

I see there's been some changes recently relating to GH Actions CI and publishing. Do you have a working example of how to publish a tree-sitter grammar on npm?

Here is my grammar:

https://github.com/olehermanse/tree-sitter-cfengine

Publishing releases on GH, pypi, and crates.io is currently working using GH Actions. I've been trying to copy what is done in tree-sitter-c and tree-sitter-typescript, however I can see that those repos have had CI related changes in the last few days, but no releases since January, so I guess they are not currently working?

Specifically, the error I encounter in GH Actions is:

make: Entering directory '/home/runner/work/tree-sitter-cfengine/tree-sitter-cfengine/build'
  TOUCH Release/obj.target/node_modules/node-addon-api/node_addon_api_except.stamp
  CXX(target) Release/obj.target/tree_sitter_cfengine_binding/bindings/node/binding.o
g++: error: unrecognized command line option ‘-std=gnu++20’; did you mean ‘-std=gnu++2a’?
make: *** [tree_sitter_cfengine_binding.target.mk:121: Release/obj.target/tree_sitter_cfengine_binding/bindings/node/binding.o] Error 1
make: Leaving directory '/home/runner/work/tree-sitter-cfengine/tree-sitter-cfengine/build'
gyp ERR! build error 

Steps to reproduce

N/A

Expected behavior

Publishing packages to npm works using the same GH Actions as the official tree-stter grammars.

Tree-sitter version (tree-sitter --version)

tree-sitter 0.24.3

Operating system/version

Ubuntu / macOS / windows

amaanq commented 1 week ago

:thinking: can't reproduce, I just published the regex grammar here https://github.com/tree-sitter/tree-sitter-regex/actions/runs/11413533364, which has the same workflow setup in the C/TS repos

Only thing I noticed in your run was that it fetched node v23, whereas regex used 22

olehermanse commented 6 days ago

Only thing I noticed in your run was that it fetched node v23, whereas regex used 22

@amaanq Thanks, that turned out to be the problem. Do you know what determines which version of node is used? I synced / downgraded dependencies to match tree-sitter-regex and now it also picks 22 and works for me.

I expect others will face the same problem, it seems like it's pretty easy to reproduce if you upgrade dependencies in tree-sitter-regex:

$ git clone git@github.com:tree-sitter/tree-sitter-regex.git
$ cd tree-sitter-regex/
$ npm update --save
$ npm install
$ npm x -- prebuildify --strip --arch x64
gyp info it worked if it ends with ok
gyp info using node-gyp@10.2.0
gyp info using node@20.12.1 | linux | x64
gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"

gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/olehermanse/code/tree-sitter-regex/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/tmp/prebuildify/node/23.0.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/tmp/prebuildify/node/23.0.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/tmp/prebuildify/node/23.0.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/olehermanse/code/tree-sitter-regex',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/olehermanse/code/tree-sitter-regex/build'
  TOUCH Release/obj.target/node_modules/node-addon-api/node_addon_api_except.stamp
  CXX(target) Release/obj.target/tree_sitter_regex_binding/bindings/node/binding.o
g++: error: unrecognized command line option ‘-std=gnu++20’; did you mean ‘-std=gnu++2a’?
make: *** [tree_sitter_regex_binding.target.mk:121: Release/obj.target/tree_sitter_regex_binding/bindings/node/binding.o] Error 1
make: Leaving directory '/home/olehermanse/code/tree-sitter-regex/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib/node_modules/node-gyp/lib/build.js:216:23)
gyp ERR! System Linux 5.15.153.1-microsoft-standard-WSL2
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild" "--target=23.0.0" "--devdir=/tmp/prebuildify/node" "--arch=x64" "--release"
gyp ERR! cwd /home/olehermanse/code/tree-sitter-regex
gyp ERR! node -v v20.12.1
gyp ERR! node-gyp -v v10.2.0
gyp ERR! not ok
node-gyp exited with 1