dodona-edu / dolos

:detective: Source code plagiarism detection
https://dolos.ugent.be
MIT License
251 stars 31 forks source link

dolos-parsers fails to build on Windows natively "No such file or directory" of binding.sln.gyp #1559

Closed daotrungkien closed 3 months ago

daotrungkien commented 3 months ago

Please help me to walk over the following error when installing dolos-lib in a nodejs project with the command:

npm install @dodona/dolos-lib

Error messages:

npm ERR! code 1
npm ERR! path D:\tmp\js\node_modules\@dodona\dolos-parsers
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.10.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.9 found at "D:\dev\anaconda3\python.exe"
npm ERR! gyp info find VS using VS2022 (17.0.32014.148) found at:
npm ERR! gyp info find VS "D:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn D:\dev\anaconda3\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'D:\\tmp\\js\\node_modules\\@dodona\\dolos-parsers\\build\\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\MICA\\AppData\\Local\\node-gyp\\Cache\\20.10.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=C:\\Users\\MICA\\AppData\\Local\\node-gyp\\Cache\\20.10.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\MICA\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\20.10.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=D:\\tmp\\js\\node_modules\\@dodona\\dolos-parsers',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'D:\\tmp\\js\\node_modules\\@dodona\\dolos-parsers\\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Traceback (most recent call last):
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 45, in <module>
npm ERR!     sys.exit(gyp.script_main())
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 688, in script_main
npm ERR!     return main(sys.argv[1:])
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 680, in main
npm ERR!     return gyp_main(args)
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 665, in gyp_main
npm ERR!     generator.GenerateOutput(flat_list, targets, data, params)
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2157, in GenerateOutput
npm ERR!     sln = MSVSNew.MSVSSolution(
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSNew.py", line 228, in __init__
npm ERR!     self.Write()
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSNew.py", line 255, in Write
npm ERR!     f = writer(self.path)
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\common.py", line 415, in WriteOnDiff
npm ERR!     return Writer()
npm ERR!   File "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\common.py", line 353, in __init__
npm ERR!     tmp_fd, self.tmp_path = tempfile.mkstemp(
npm ERR!   File "D:\dev\anaconda3\lib\tempfile.py", line 341, in mkstemp
npm ERR!     return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
npm ERR!   File "D:\dev\anaconda3\lib\tempfile.py", line 256, in _mkstemp_inner
npm ERR!     fd = _os.open(file, flags, 0o600)
npm ERR! FileNotFoundError: [Errno 2] No such file or directory: 'D:\\tmp\\js\\node_modules\\@dodona\\dolos-parsers\\build\\bash\\binding.sln.gyp.qn9a2l5_.tmp'
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:271:18)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22631
npm ERR! gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\tmp\js\node_modules\@dodona\dolos-parsers
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\MICA\AppData\Local\npm-cache\_logs\2024-06-10T06_54_45_756Z-debug-0.log

I am using Windows 11, MSVS 2022 Community Edition with C/C++ fully optioned, Python 3.10.9, NodeJS 20.10.0, npm 10.2.3, node-gyp 10.1.0 installed as global package. The NodeJS project is a start-up one created with npm init -y.

Notably, I think the most important error line is the following one but I don't know why it happens and how to fix:

npm ERR! FileNotFoundError: [Errno 2] No such file or directory: 'D:\\tmp\\js\\node_modules\\@dodona\\dolos-parsers\\build\\bash\\binding.sln.gyp.qn9a2l5_.tmp'

Thank you.

rien commented 3 months ago

Hi @daotrungkien, unfortunately we've bumped on this issue earlier (https://github.com/dodona-edu/dolos/actions/runs/8631612300/job/23660392187?pr=1458) and haven't found a fix.

Building dolos-parsers seems to be broken on Windows natively. There line you picked up is indeed is an sln-file that should be generated (I think by node-gyp) and that does seem to have happened. I unfortunately don't know enough of how node-gyp works on Windows and I don't have the bandwidth to fix this currently.

Feel free to dig deeper in this issue to find the root cause.

Dolos should work on Windows within WSL though, I hope that is something that could work for you?

daotrungkien commented 3 months ago

Thanks @rien, I followed your instruction and successfully made it work under WSL. Sorry I am not expert in node-gyp neither :)

So as this issue is redundant, I will close it.