nodejs / node-gyp

Node.js native addon build tool
MIT License
9.87k stars 1.79k forks source link

MSBuild fails on Gitlab Runner #2629

Closed idoodler closed 4 months ago

idoodler commented 2 years ago

I am developing a C++ Module for node.js which builds fine on my local Windows machine and on our buildserver (Windows 11 arm), however when building it with our Gitlab CI/CD on the very same machine node-gyp fails with exit code 1, specifically MSBuild.exe.

Verbose output (from npm or node-gyp): ``` gyp info it worked if it ends with ok gyp info using node-gyp@8.4.1 gyp info using node@16.14.0 | win32 | x64 gyp info ok gyp info it worked if it ends with ok gyp info using node-gyp@8.4.1 gyp info using node@16.14.0 | win32 | x64 gyp info find Python using Python version 3.10.2 found at "C:\Users\appdev\AppData\Local\Programs\Python\Python310\python.exe" gyp info find VS using VS2017 (15.9.28307.1525) found at: gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" gyp info find VS run with --verbose for detailed information gyp info spawn C:\Users\appdev\AppData\Local\Programs\Python\Python310\python.exe gyp info spawn args [ gyp info spawn args 'C:\\Users\\appdev\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\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:\\GitLab-runner\\builds\\C5Tv-XQ4\\0\\App\\nodesip\\build\\config.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\\Users\\appdev\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\node-gyp\\Cache\\16.14.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:\\WINDOWS\\system32\\config\\systemprofile\\AppData\\Local\\node-gyp\\Cache\\16.14.0', gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\appdev\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp', gyp info spawn args '-Dnode_lib_file=C:\\\\WINDOWS\\\\system32\\\\config\\\\systemprofile\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.14.0\\\\<(target_arch)\\\\node.lib', gyp info spawn args '-Dmodule_root_dir=C:\\GitLab-runner\\builds\\C5Tv-XQ4\\0\\App\\nodesip', 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:\\GitLab-runner\\builds\\C5Tv-XQ4\\0\\App\\nodesip\\build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp info ok gyp info it worked if it ends with ok gyp info using node-gyp@8.4.1 gyp info using node@16.14.0 | win32 | x64 gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe gyp info spawn args [ 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' gyp info spawn args ] gyp ERR! build error gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\appdev\AppData\Roaming\nvm\v16.14.0\node_modules\npm\node_modules\node-gyp\lib\build.js:[194](http://gitlab.loxone.com/App/nodesip/-/jobs/230865#L194):23) gyp ERR! stack at ChildProcess.emit (node:events:520:28) gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) gyp ERR! System Windows_NT 10.0.2[200](http://gitlab.loxone.com/App/nodesip/-/jobs/230865#L200)0 gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\appdev\\AppData\\Roaming\\nvm\\v16.14.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--target_arch=x64" "--target_platform=win32" "--module=C:\\GitLab-runner\\builds\\C5Tv-XQ4\\0\\App\\nodesip\\lib\\binding\\Release\\v1.2.2\\node-v93-win32-x64\\nodesip.node" "--module_name=nodesip" "--module_path=C:\\GitLab-runner\\builds\\C5Tv-XQ4\\0\\App\\nodesip\\lib\\binding\\Release\\v1.2.2\\node-v93-win32-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93" gyp ERR! cwd C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip ```

It works on the same machine if I build it manually, but it won't work using the Gitlab Runner. The Gitlab Runner is running as a service on the Windows PC

Edit: Apparently this is the issue: Cannot open include file: 'node_version.h'

MSBuild Output ``` [nodesip] Removing "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\lib\binding\Release\v1.2.2\node-v93-win32-x64" Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 3/9/2022 7:40:38 PM. Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\binding.sln" on node 1 (default targets). ValidateSolutionConfiguration: Building solution configuration "Release|x64". Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\binding.sln" (1) is building "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\action_after_build.vcxproj.metaproj" (2) on node 1 (default targets). Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\action_after_build.vcxproj.metaproj" (2) is building "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\nodesip.vcxproj" (3) on node 1 (default targets). PrepareForBuild: Creating directory "Release\obj\nodesip\". Creating directory "Release\obj\nodesip\nodesip.tlog\". InitializeBuildStatus: Creating "Release\obj\nodesip\nodesip.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. MakeDirsForCl: Creating directory "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\Release\obj\nodesip\native". Creating directory "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\Release\obj\nodesip\native\shared\MyAccount". Creating directory "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\Release\obj\nodesip\native\shared\MyCall". Creating directory "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\Release\obj\nodesip\native\pjsua2". ClCompile: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\CL.exe /c /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\include\node" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\src" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\config" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\deps\openssl\openssl\include" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\deps\uv\include" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\deps\zlib" /I"C:\WINDOWS\system32\config\systemprofile\AppData\Local\node-gyp\Cache\16.14.0\deps\v8\include" /I..\node_modules\nan /I"..\native\pjsip\platforms\win\src_x64\pjlib-util\include" /I..\native\pjsip\platforms\win\src_x64\pjlib\include /I..\native\pjsip\platforms\win\src_x64\pjmedia\include /I..\native\pjsip\platforms\win\src_x64\pjnath\include /I..\native\pjsip\platforms\win\src_x64\pjsip\include /I..\native\pjsip\platforms\win\src_x64\third_party\bdsound\include /I..\native\pjsip\platforms\win\src_x64\third_party\resample\include /I..\native\pjsip\platforms\win\src_x64\third_party\speex\include /I..\native\pjsip\platforms\win\src_x64\third_party\srtp\crypto\include /I..\native\pjsip\platforms\win\src_x64\third_party\srtp\include /I..\native\pjsip\platforms\win\src_x64\third_party\threademulation\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc_aec3\src\common_audio\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc_aec3\src\common_audio\resampler\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc_aec3\src\common_audio\signal_processing\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc_aec3\src\modules\audio_processing\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc_aec3\src\system_wrappers\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc\src\webrtc\common_audio\signal_processing\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc\src\webrtc\modules\audio_processing\aec\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc\src\webrtc\modules\audio_processing\aecm\include /I..\native\pjsip\platforms\win\src_x64\third_party\webrtc\src\webrtc\modules\audio_processing\ns\include /I..\native\pjsip\platforms\win\src_x64\third_party\yuv\include /Z7 /nologo /W3 /WX- /diagnostics:classic /MP /Ox /Ob2 /Oi /Ot /Oy /GL /D NODE_GYP_MODULE_NAME=nodesip /D USING_UV_SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8_IMMINENT_DEPRECATION_WARNINGS /D _GLIBCXX_USE_CXX11_ABI=1 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _HAS_EXCEPTIONS=0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D __WIN__ /D PJ_WIN32=1 /D PJ_M_I386=1 /D BUILDING_NODE_EXTENSION /D "HOST_BINARY=\"node.exe\"" /D _WINDLL /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj\nodesip\\native\sip-Wrapper.obj" /Fd"Release\obj\nodesip\vc141.pdb" /Gd /TP /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /wd4244 /wd4267 /FC /errorReport:queue /Zc:__cplusplus "..\native\sip-Wrapper.cc" sip-Wrapper.cc c:\gitlab-runner\builds\c5tv-xq4\0\app\nodesip\node_modules\nan\nan.h(24): fatal error C1083: Cannot open include file: 'node_version.h': No such file or directory [C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\nodesip.vcxproj] Done Building Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\nodesip.vcxproj" (default targets) -- FAILED. Done Building Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\action_after_build.vcxproj.metaproj" (default targets) -- FAILED. Done Building Project "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\binding.sln" (default targets) -- FAILED. Build FAILED. "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\binding.sln" (default target) (1) -> "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\action_after_build.vcxproj.metaproj" (default target) (2) -> "C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\nodesip.vcxproj" (default target) (3) -> (ClCompile target) -> c:\gitlab-runner\builds\c5tv-xq4\0\app\nodesip\node_modules\nan\nan.h(24): fatal error C1083: Cannot open include file: 'node_version.h': No such file or directory [C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\build\nodesip.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:02.51 Failed to execute 'C:\Program Files (x86)\nodejs\node.exe C:\Users\appdev\AppData\Roaming\nvm\v16.14.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --target_arch=x64 --loglevel=verbose --module=C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\lib\binding\Release\v1.2.2\node-v93-win32-x64\nodesip.node --module_name=nodesip --module_path=C:\GitLab-runner\builds\C5Tv-XQ4\0\App\nodesip\lib\binding\Release\v1.2.2\node-v93-win32-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) ```
idoodler commented 2 years ago

I digged into this issue.

It appears as if there are two users which have their own node-gyp caching folders.

On my system each node-gyp caching folder contains the node_version.h. The solution created in the build folder correctly contains the header search path leading to the users node-gyp caching folder.

So apparently everything looks correct?

cclauss commented 2 years ago

So can this issue be closed?

idoodler commented 2 years ago

@cclauss No, the issue still occurs and isn't fixed. I was just telling my findings and that everything looks fine to me, but it just won't work. The error is always the output as seen in the MSBuild Output in my original post

tjohnston-cd commented 6 months ago

Sorry to revive this very old thread but ... @idoodler did you ever resolve this?

I'm chasing a similar issue which has nothing to do with node-gyp or nodejs. It seems like a problem caused by the gitlab runner. Just curious if you had any additional knowledge a couple years later..

StefanStojanovic commented 5 months ago

This issue seems no longer relevant as it uses a no longer supported version of Node and has been stale for a long time (last comment is not directly connected to node-gyp). If there are no objections, I will close this issue next Mon-Tue. In case something similar happens again please open a new issue.