node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

MSYS2-MinGW64: Auto Generated Makefiles Give Error: target pattern contains no '%'

Open aamirglb opened this issue 10 months ago • 3 comments

Platform: MSYS2-MinGW64 on Windows 11 Node Version: v23.5.0 Compiler: GCC 14.2.0 make: GNU Make 4.4.1 Module: Pelias Interpolation

I'm trying to run the Pelias/Interpolation server on MSYS2-MinGW64. This module has dependencies on node-postal and better-sqlite3 node modules. Both this modules has addon's which gets build while installing these packages with npm install.

While installing these packages. I'm getting the following error:

$ npm install
npm warn deprecated [email protected]: Use String.prototype.trim() instead
npm warn deprecated [email protected]: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
npm warn deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm warn deprecated @hapi/[email protected]: Moved to 'npm install @sideway/pinpoint'
npm warn deprecated @hapi/[email protected]: Moved to 'npm install @sideway/formula'
npm warn deprecated @hapi/[email protected]: Switch to 'npm install joi'
npm warn deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm warn deprecated [email protected]: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net
npm error code 1
npm error path C:\temp\postal-test\msys64\home\aamir.ali\interpolation\node_modules\better-sqlite3
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild --release
npm error make: Entering directory '/home/aamir.ali/interpolation/node_modules/better-sqlite3/build'
npm error make: Leaving directory '/home/aamir.ali/interpolation/node_modules/better-sqlite3/build'
npm error prebuild-install warn install A dynamic link library (DLL) initialization routine failed.
npm error \\?\C:\temp\postal-test\msys64\home\aamir.ali\interpolation\node_modules\better-sqlite3\build\Release\better_sqlite3.node
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | win32 | x64
npm error gyp info find Python using Python version 3.12.8 found at "C:/temp/postal-test/msys64/mingw64/bin/python3.exe"
npm error gyp info spawn C:/temp/postal-test/msys64/mingw64/bin/python3.exe
npm error gyp info spawn args [
npm error gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\temp\\postal-test\\msys64\\home\\aamir.ali\\interpolation\\node_modules\\better-sqlite3\\build\\config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\include\\node\\common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=C:\\temp\\postal-test\\msys64\\mingw64',
npm error gyp info spawn args '-Dnode_gyp_dir=C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=C:\\temp\\postal-test\\msys64\\mingw64\\lib\\libnode.dll.a',
npm error gyp info spawn args '-Dmodule_root_dir=C:\\temp\\postal-test\\msys64\\home\\aamir.ali\\interpolation\\node_modules\\better-sqlite3',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm error better_sqlite3.target.mk:93: *** target pattern contains no '%'.  Stop.
npm error gyp ERR! build error
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (C:\temp\postal-test\msys64\mingw64\lib\node_modules\npm\node_modules\node-gyp\lib\build.js:216:23)
npm error gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System MINGW32_NT-10.0 10.0.22631
npm error gyp ERR! command "C:\\temp\\postal-test\\msys64\\mingw64\\bin\\node.exe" "C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
npm error gyp ERR! cwd C:\temp\postal-test\msys64\home\aamir.ali\interpolation\node_modules\better-sqlite3
npm error gyp ERR! node -v v23.5.0
npm error gyp ERR! node-gyp -v v11.0.0
npm error gyp ERR! not ok
npm error A complete log of this run can be found in: C:\Users\aamir.ali\AppData\Local\npm-cache\_logs\2025-01-17T19_59_42_101Z-debug-0.log

Installing the node modules on Windows 11 works without any error. Can anyone please clarify if I'm making anything wrong or this is an issue with node-gyp on MSYS-MinGW64. Any help in resolving this issue is highly appreciated.

Thanks in advance.

aamirglb avatar Jan 17 '25 20:01 aamirglb

npm error better_sqlite3.target.mk:93: *** target pattern contains no '%'. Stop.

Duplicate of

  • #2950
  • #3004
  • Plus four closed issues... https://github.com/search?q=repo%3Anodejs%2Fnode-gyp+better_sqlite3&type=issues

Perhaps this is an issue for https://www.npmjs.com/package/better-sqlite3

cclauss avatar Jan 17 '25 21:01 cclauss

Hi @cclauss, Thanks a lot for your reply.

I get the exact same error for openvenues/node-postal package as well. This package has a dependency on openvenues/libpostal. node-postal is a binding for libpostal.

This package installs successfully on Linux/WSL but fails to install on MSYS2-MinGW64.

Her is the binding.gyp which I customized for MSYS2 environment.

{
    "targets": [
        {
            "target_name": "expand",
            "sources": [
                "src/expand.cc"
            ],
            "libraries": [
                "-lpostal", "-L/mingw64/lib"
            ],
            "include_dirs": [
                "<!(node -e \"require('nan')\")",
                "/mingw64/include",
            ]
        },
        {
            "target_name": "parser",
            "sources": [
                "src/parser.cc"
            ],
            "libraries": [
                "-lpostal", "-L/mingw64/lib"
            ],
            "include_dirs": [
                "<!(node -e \"require('nan')\")",
                "/mingw64/include",
            ]
        }
    ]
}

Here is the output of npm install:

aamir.ali@LC100196 MINGW64 ~/tbd/node-postal
$ npm install
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported

> [email protected] install
> (node-gyp rebuild) || (exit 0)

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.12.8 found at "C:/temp/postal-test/msys64/mingw64/bin/python3.exe"

gyp info spawn C:/temp/postal-test/msys64/mingw64/bin/python3.exe
gyp info spawn args [
gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\lib\\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 'make',
gyp info spawn args '-I',
gyp info spawn args 'C:\\temp\\postal-test\\msys64\\home\\aamir.ali\\tbd\\node-postal\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\temp\\postal-test\\msys64\\mingw64\\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:\\temp\\postal-test\\msys64\\mingw64',
gyp info spawn args '-Dnode_gyp_dir=C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\temp\\postal-test\\msys64\\mingw64\\lib\\libnode.dll.a',
gyp info spawn args '-Dmodule_root_dir=C:\\temp\\postal-test\\msys64\\home\\aamir.ali\\tbd\\node-postal',
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/aamir.ali/tbd/node-postal/build'
expand.target.mk:87: *** target pattern contains no '%'.  Stop.
make: Leaving directory '/home/aamir.ali/tbd/node-postal/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (C:\temp\postal-test\msys64\mingw64\lib\node_modules\npm\node_modules\node-gyp\lib\build.js:216:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System MINGW32_NT-10.0 10.0.22631
gyp ERR! command "C:\\temp\\postal-test\\msys64\\mingw64\\bin\\node.exe" "C:\\temp\\postal-test\\msys64\\mingw64\\lib\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\temp\postal-test\msys64\home\aamir.ali\tbd\node-postal
gyp ERR! node -v v23.5.0
gyp ERR! node-gyp -v v11.0.0
gyp ERR! not ok

The following lines in the auto generated expand.target.mk Makefile are causing the issues:

# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.
$(OBJS): TOOLSET := $(TOOLSET)
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))  $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))

In expand.target.mk, I added a info statement to display the value of OBJS variable, $(info OBJS: $(OBJS)) and it gets evaluated as

$ make -f build/expand.target.mk
OBJS: .target/expand/src/expand.o .target/expand/C:/temp/postal-test/msys64/mingw64/lib/node_modules/npm/node_modules/node-gyp/src/win_delay_load_hook.o
build/expand.target.mk:89: *** target pattern contains no '%'.  Stop.

Looks like, node-gyp is trying to link win_delay_load_hook.o which has a : in its path. Could this be a potential issues?

Here is the comparison of expand.target.mk file created on Linux/WSL and MSYS2-MinGW64:

Image

To me it looks like, the Makefile generated by node-gyp on MSYS2-MinGW64 has some issues which causes the installation of both node-postal and better-sqlite to fail.

Any thoughts from your side? Do you have any test cases to test node-gyp on MSYS2-MinGW64?

aamirglb avatar Jan 18 '25 08:01 aamirglb

This is a path conversion bug try to debug how this path is generated and use MSYS2_ARG_CONV_EXCL="*"

Kreijstal avatar Feb 10 '25 08:02 Kreijstal

This is a path conversion bug try to debug how this path is generated and use MSYS2_ARG_CONV_EXCL="*"

I find the issue caused by node -e \"require('nan')\") return a path with double quotes, so g++/gcc cannot handle it correctly.

I have submitted a pr:

  • Kreijstal/node-gyp#3

lsq avatar Sep 27 '25 08:09 lsq