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

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

Open
olehermanse opened this issue Oct 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@olehermanse
Copy link

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

@olehermanse olehermanse added the bug Something isn't working label Oct 18, 2024
@amaanq
Copy link
Member

amaanq commented Oct 19, 2024

🤔 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

@ObserverOfTime ObserverOfTime transferred this issue from tree-sitter/tree-sitter Oct 19, 2024
@olehermanse
Copy link
Author

olehermanse commented Oct 20, 2024

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 [email protected]: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 [email protected]
gyp info using [email protected] | 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants