Better output for bad target_name (was: Incorrect Error logs on v5.0.0)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Description
- Node Version: 10.16.0
- Platform: Windows10
- Compiler: VS2019
- Module: rebuild
example: https://github.com/Himself65/kcp-node/tree/bug, you can reproduce it with run yarn install or npm install
when building.gyp contains target_name char -, it shows the incorrect error logs.
{
'targets': [
{
'target_name': 'kcp-',
'sources': [ './lib/kcp-node.cc' ]
}
]
}
and I think it should log like incorrect target_name format but it's C++ grammar error, and coding is absolutely right
Verbose output (from npm or node-gyp):
C:\Users\himself65\Desktop\Github\kcp-node>yarn
yarn install v1.16.0
[1/4] Resolving packages...
success Already up-to-date.
$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.0
gyp info using node@10.16.0 | win32 | x64
gyp info find Python using Python version 2.7.16 found at "C:\Python27\python.exe"
gyp info find VS using VS2019 (16.1.29009.5) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [ 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.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=C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.0',
gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.0\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\Users\\himself65\\Desktop\\Github\\kcp-node',
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 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
kcp-node.cc
win_delay_load_hook.cc
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2143: 语法错误: 缺少“;”(在“-”的前面) [C:\Users\himself65\Desktop\Gi
thub\kcp-node
\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): warning C4229: 使用了记时错误: 忽略数据上的修饰符 [C:\Users\himself65\Desktop\
Github\kcp-node
\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2182: “_register_kcp”: 非法使用“void”类型 [C:\Users\himself65\Deskt
op\Github
\kcp-node\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2143: 语法错误: 缺少“)”(在“-”的前面) [C:\Users\himself65\Desktop\Gi
thub\kcp-node
\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2165: “左侧修饰符”: 不能修改指向数据的指针 [C:\Users\himself65\Deskto
p\Github\kcp-node
\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2059: 语法错误:“)” [C:\Users\himself65\Desktop\Github\kcp-node\build\
kcp-.
vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2086: “int _register_kcp”: 重定义 [C:\Users\himself65\Desktop\Github\
kcp-
node\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34): message : 参见“_register_kcp”的声明 [C:\Users\himself65\Desktop\Github\kcp-nod
e\buil
d\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2143: 语法错误: 缺少“;”(在“{”的前面) [C:\Users\himself65\Desktop\Gi
thub\kcp-node
\build\kcp-.vcxproj]
C:\Users\himself65\Desktop\Github\kcp-node\lib\kcp-node.cc(34,1): error C2447: “{”: 缺少函数标题(是否是老式的形式表?) [C:\Users\himself65\Desk
top\Github\kcp-n
ode\build\kcp-.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\himself65\Desktop\Github\kcp-node\node_modules\node-gyp\lib\build.js:190:23)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp\\bin\\node-gyp.js
" "rebuild"
gyp ERR! cwd C:\Users\himself65\Desktop\Github\kcp-node
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v5.0.0
gyp ERR! not ok
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
but when I run it without char - in target_name, it runs successfully.
{
'targets': [
{
'target_name': 'kcp',
'sources': [ './lib/kcp-node.cc' ]
}
]
}
Verbose output (from npm or node-gyp):
C:\Users\himself65\Desktop\Github\kcp-node>yarn
yarn install v1.16.0
[1/4] Resolving packages...
success Already up-to-date.
$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.0
gyp info using node@10.16.0 | win32 | x64
gyp info find Python using Python version 2.7.16 found at "C:\Python27\python.exe"
gyp info find VS using VS2019 (16.1.29009.5) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [ 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.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=C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.0',
gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\Users\\himself65\\AppData\\Local\\node-gyp\\Cache\\10.16.0\\<(target_arch)\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\Users\\himself65\\Desktop\\Github\\kcp-node',
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 'C:\\Users\\himself65\\Desktop\\Github\\kcp-node\\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
在此解决方案中一次生成一个项目。若要启用并行生成,请添加“-m”开关。
kcp-node.cc
win_delay_load_hook.cc
正在创建库 C:\Users\himself65\Desktop\Github\kcp-node\build\Release\kcp.lib 和对象 C:\Users\himself65\Desktop\Github\kcp-node\build\Release\k
cp.exp
正在生成代码
Previous IPDB not found, fall back to full compilation.
All 26 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
kcp.vcxproj -> C:\Users\himself65\Desktop\Github\kcp-node\build\Release\\kcp.node
gyp info ok
Done in 4.22s.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure from the linked example by running yarn install or npm install with the shown binding.gyp target_name value. Start at the node-gyp rebuild entry point and inspect how the target_name is handled before the generated C++ build reaches lib/kcp-node.cc. Done means invalid target_name values produce a clear format error instead of compiler errors, while the valid kcp example still builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, python
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100