launchql / libpg-query-node

libpg_query PG port for node.js
MIT License
56 stars 24 forks source link

Window support (depends on llbpg_query) #22

Closed Eprince-hub closed 7 months ago

Eprince-hub commented 2 years ago

Installing libpg-query on windows 10/11 failed with this long errors below

$ yarn add libpg-query
yarn add v1.22.19
[1/4] �  Resolving packages...
[2/4] �  Fetching packages...
[3/4] �  Linking dependencies...
warning "@ts-safeql/eslint-plugin > @typescript-eslint/utils > @typescript-eslint/typescript-estree > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] �  Building fresh packages...
[-/4] ⠂ waiting...
[-/4] ⠄ waiting...
[3/4] ⠄ libpg-query
error C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.10
node-pre-gyp info using node@18.5.0 | win32 | x64
node-pre-gyp info check checked for "C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query\build\Release\queryparser.node" (not found)
node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v108-win32-x64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v108-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for libpg-query@13.2.5 and node@18.5.0 (node-v108 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v108-win32-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@8.4.1
gyp info using node@18.5.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@18.5.0 | win32 | x64
gyp info find Python using Python version 3.9.6 found at "C:\Users\Victor\AppData\Local\Programs\Python\Python39\python.exe"
gyp info find VS using VS2017 (15.9.28307.1585) 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\Victor\AppData\Local\Programs\Python\Python39\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\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\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\libpg-query\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Victor\\AppData\\Local\\node-gyp\\Cache\\18.5.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\\Victor\\AppData\\Local\\node-gyp\\Cache\\18.5.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\Victor\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.5.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\libpg-query',
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\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\libpg-query\\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@18.5.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 ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  nothing.c
  win_delay_load_hook.cc
  nothing.vcxproj -> C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query\build\Release\\nothing.lib
  prebuild_dependencies
  The system cannot find the path specified.
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 1. [C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query\build\queryparser.vcxproj]
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\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:537:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Windows_NT 10.0.22000
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\libpg-query\\build\\Release\\queryparser.node" "--module_name=queryparser" "--module_path=C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\libpg-query\\build\\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108"
gyp ERR! cwd C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query
gyp ERR! node -v v18.5.0
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query\build\Release\queryparser.node --module_name=queryparser --module_path=C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:537:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
node-pre-gyp ERR! System Windows_NT 10.0.22000
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Victor\\projects\\debugging-programs\\reproduce-install-peerdeps-error\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\libpg-query
node-pre-gyp ERR! node -v v18.5.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.10
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Victor\projects\debugging-programs\reproduce-install-peerdeps-error\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Use

I think libpg-query doesn't support windows machines as pointed out in this issue here https://github.com/pyramation/pgsql-parser/issues/24

OS: Windows 10 and Windows 11 Node Version: 18

I have tried the installation in the following command lines VSCode Terminal Hyper Windows command prompt Windows PowerShell

In every instance, the same error was returned

Steps to reproduce You can try this installation on this repo A computer running windows OS is needed to reproduce this error

clone project

git clone https://github.com/Eprince-hub/libpg-query-installation-error.git

cd into project

cd libpg-query-installation-error

install libpg-query

yarn add libpg-query
or
npm i libpg-query
pyramation commented 2 years ago

Hi! I don't use windows so would have a hard time testing, reproducing or fixing this. Happy to accept a PR.

Eprince-hub commented 2 years ago

Hello, Thanks for your reply. I would like to look into how I can do this but I am going to need a lot of help from you. I have not done anything with C++ before. Will not be immediate though as I have other things on my schedule now, but if I see an indication of possible help from you, I will try to map out a time to look into it.

baa-ableton commented 2 years ago

Hello all involved,

My team member is also affected by this.

Same 404 error reported by npm, on the following resource: https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.4-node-v108-win32-x64.tar.gz

I went a few directories up on the URI and: https://supabase-public-artifacts-bucket.s3.amazonaws.com/

It doesn't look like there are any windows packages on the S3 bucket. Only linux and darwin versions.

nichita-pasecinic commented 2 years ago

Same here, fails to install libpg-query

ERROR Stack Trace ``` npm ERR! code 1 npm ERR! path C:\Jivy\postgres-meta\node_modules\libpg-query npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch. npm ERR! nothing.c npm ERR! win_delay_load_hook.cc npm ERR! nothing.vcxproj -> C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release\\nothing.lib npm ERR! prebuild_dependencies npm ERR! The system cannot find the path specified. npm ERR! C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for '..\binding.gyp' exited with code 1. [C:\Jivy\postgres-meta\node_modules\libpg-query\build\queryparser.vcxproj] npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release\queryparser.node --module_name=queryparser --module_path=C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) npm ERR! node-pre-gyp info it worked if it ends with ok npm ERR! node-pre-gyp info using node-pre-gyp@1.0.10 npm ERR! node-pre-gyp info using node@16.18.0 | win32 | x64 npm ERR! node-pre-gyp info check checked for "C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release\queryparser.node" (not found) npm ERR! node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v93-win32-x64.tar.gz npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v93-win32-x64.tar.gz npm ERR! node-pre-gyp WARN Pre-built binaries not installable for libpg-query@13.2.5 and node@16.18.0 (node-v93 ABI, unknown) (falling back to source compile with node-gyp) npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v13.2.5-node-v93-win32-x64.tar.gz npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.1.0 npm ERR! gyp info using node@16.18.0 | win32 | x64 npm ERR! gyp info ok npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.1.0 npm ERR! gyp info using node@16.18.0 | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.8 found at "C:\Python310\python.exe" npm ERR! gyp http GET https://nodejs.org/download/release/v16.18.0/node-v16.18.0-headers.tar.gz npm ERR! gyp http 200 https://nodejs.org/download/release/v16.18.0/node-v16.18.0-headers.tar.gz npm ERR! gyp http GET https://nodejs.org/download/release/v16.18.0/SHASUMS256.txt npm ERR! gyp http GET https://nodejs.org/download/release/v16.18.0/win-x86/node.lib npm ERR! gyp http GET https://nodejs.org/download/release/v16.18.0/win-arm64/node.lib npm ERR! gyp http GET https://nodejs.org/download/release/v16.18.0/win-x64/node.lib npm ERR! gyp http 200 https://nodejs.org/download/release/v16.18.0/SHASUMS256.txt npm ERR! gyp http 200 https://nodejs.org/download/release/v16.18.0/win-x86/node.lib npm ERR! gyp http 404 https://nodejs.org/download/release/v16.18.0/win-arm64/node.lib npm ERR! gyp http 200 https://nodejs.org/download/release/v16.18.0/win-x64/node.lib npm ERR! gyp info find VS using VS2019 (16.11.32929.386) found at: npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" npm ERR! gyp info find VS run with --verbose for detailed information npm ERR! gyp info spawn C:\Python310\python.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'C:\\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 'C:\\Jivy\\postgres-meta\\node_modules\\libpg-query\\build\\config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\\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\\NichitaPasecinic-JG\\AppData\\Local\\node-gyp\\Cache\\16.18.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\\NichitaPasecinic-JG\\AppData\\Local\\node-gyp\\Cache\\16.18.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\NichitaPasecinic-JG\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.18.0\\\\<(target_arch)\\\\node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\\Jivy\\postgres-meta\\node_modules\\libpg-query', 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 'C:\\Jivy\\postgres-meta\\node_modules\\libpg-query\\build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info ok npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.1.0 npm ERR! gyp info using node@16.18.0 | win32 | x64 npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'build/binding.sln', npm ERR! gyp info spawn args '/clp:Verbosity=minimal', npm ERR! gyp info spawn args '/nologo', npm ERR! gyp info spawn args '/p:Configuration=Release;Platform=x64' npm ERR! gyp info spawn args ] npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1 npm ERR! gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:201:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) npm ERR! gyp ERR! System Windows_NT 10.0.19044 npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Jivy\\postgres-meta\\node_modules\\libpg-query\\build\\Release\\queryparser.node" "--module_name=queryparser" "--module_path=C:\\Jivy\\postgres-meta\\node_modules\\libpg-query\\build\\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93" npm ERR! gyp ERR! cwd C:\Jivy\postgres-meta\node_modules\libpg-query npm ERR! gyp ERR! node -v v16.18.0 npm ERR! gyp ERR! node-gyp -v v9.1.0 npm ERR! gyp ERR! not ok npm ERR! node-pre-gyp ERR! build error npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release\queryparser.node --module_name=queryparser --module_path=C:\Jivy\postgres-meta\node_modules\libpg-query\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) npm ERR! node-pre-gyp ERR! stack at ChildProcess. (C:\Jivy\postgres-meta\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23) npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28) npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16) npm ERR! node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19044 npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Jivy\\postgres-meta\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" npm ERR! node-pre-gyp ERR! cwd C:\Jivy\postgres-meta\node_modules\libpg-query npm ERR! node-pre-gyp ERR! node -v v16.18.0 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.10 npm ERR! node-pre-gyp ERR! not ok npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\NichitaPasecinic-JG\AppData\Local\npm-cache\_logs\2022-10-15T10_44_36_207Z-debug-0.log ```
pyramation commented 2 years ago

The underlying issue is in the library that we depend on, libpq_query? Either way, all of the contributors use either mac or linux, and would need your help to make a PR to fix this.

So if there is anyone out there (on Windows) that needs this feature, please dig in and help your community! We'll gladly merge a PR that is proven to fix this issue.

nichita-pasecinic commented 2 years ago

@pyramation If I'd know or work with C++ I'd surely investigated it. Nevertheless thank for a quick reply. I do think there should be some note or disclaimer section with information regarding that the solution is not OS agnostic and specifically does not work/compile/build/whatever for windows systems.

Thanks!

pyramation commented 2 years ago

Here is the relevant issue, thanks for note @nichita-pasecinic

https://github.com/pganalyze/libpg_query/issues/44

karlhorky commented 1 year ago

Hm, wonder if using WebAssembly in libpg-query-node would be an option (one of the ideas I had in https://github.com/pganalyze/libpg_query/issues/44), copying here for visibility:


Wonder if an unconventional alternative would be to compile the C code to WebAssembly (Wasm) using something like emscripten, similar to how Neon.tech compiles WolfSSL to Wasm (Cloudflare blog post)

Of course, ideally libpg_query can be set up to be compiled directly to a binary on Windows - better performance, lower overhead. But maybe compiling to Wasm offers a workaround... 🤔 Maybe also useful for other projects / environments which cannot compile to binaries too...

Also, if the compiled Wasm could be published to npm, then it may offer a way to avoid the compilation step every time thelibpg-query package is installed with npm - for example when packages that depend on it are installed such as the ESLint plugin SafeQL - @ts-safeql/eslint-plugin. Avoiding this compilation step would make installation much faster.

@RReverser recently ported Sharp to WebAssembly, and used the emnapi library below, which may be an easier path forward with wasm:

gregnr commented 1 year ago

I managed to get this library to work in the browser via WASM. Here's the PR: https://github.com/pyramation/libpg-query-node/pull/34

I used emnapi as you suggested meaning no new bindings needed to be built - we simply piggyback on the existing Node-API C++ bindings and target WASM via Emscripten. Such a great tool!

karlhorky commented 1 year ago

@gregnr amazing, thanks so much for taking the time to look at this!! 🔥🔥

I'll be watching that PR closely, and will help with testing where I can!

amitkinor commented 11 months ago

same problem here. npm ERR! code 1 npm ERR! path C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build npm ERR! nothing.c npm ERR! win_delay_load_hook.cc npm ERR! nothing.vcxproj -> C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release\nothing.lib npm ERR! prebuild_dependencies npm ERR! The system cannot find the path specified. npm ERR! C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for '..\binding.gyp' exited with code 1. [C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\queryparser.vcxproj] npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release\queryparser.node --module_name=queryparser --module_path=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1) npm ERR! node-pre-gyp info it worked if it ends with ok npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11 npm ERR! node-pre-gyp info using node@18.18.2 | win32 | x64 npm ERR! node-pre-gyp info check checked for "C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release\queryparser.node" (not found) npm ERR! node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-win32-x64.tar.gz npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-win32-x64.tar.gz npm ERR! node-pre-gyp WARN Pre-built binaries not installable for libpg-query@15.0.2 and node@18.18.2 (node-v108 ABI, unknown) (falling back to source compile with node-gyp) npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v15.0.2-node-v108-win32-x64.tar.gz npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.4.0 npm ERR! gyp info using node@18.18.2 | win32 | x64 npm ERR! gyp info ok npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.4.0 npm ERR! gyp info using node@18.18.2 | win32 | x64 npm ERR! gyp info find Python using Python version 3.11.3 found at "C:\Python311\python.exe" npm ERR! gyp info find VS using VS2022 (17.8.34316.72) found at: npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" npm ERR! gyp info find VS run with --verbose for detailed information npm ERR! gyp info spawn C:\Python311\python.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\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 'C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp\addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\Users\Amit\AppData\Local\node-gyp\Cache\18.18.2\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\Amit\AppData\Local\node-gyp\Cache\18.18.2', npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\Users\\Amit\\AppData\\Local\\node-gyp\\Cache\\18.18.2\\<(target_arch)\\node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query', 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 'C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info ok npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.4.0 npm ERR! gyp info using node@18.18.2 | win32 | x64 npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'build/binding.sln', npm ERR! gyp info spawn args '/clp:Verbosity=minimal', npm ERR! gyp info spawn args '/nologo', npm ERR! gyp info spawn args '/p:Configuration=Release;Platform=x64' npm ERR! gyp info spawn args ] npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1 npm ERR! gyp ERR! stack at ChildProcess.onExit (C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp\lib\build.js:203:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:517:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:292:12) npm ERR! gyp ERR! System Windows_NT 10.0.25997 npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release\queryparser.node" "--module_name=queryparser" "--module_path=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v108" npm ERR! gyp ERR! cwd C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query npm ERR! gyp ERR! node -v v18.18.2 npm ERR! gyp ERR! node-gyp -v v9.4.0 npm ERR! gyp ERR! not ok npm ERR! node-pre-gyp ERR! build error npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Amit\AppData\Roaming\nvm\v18.18.2\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release\queryparser.node --module_name=queryparser --module_path=C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query\build\Release --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v108' (1) npm ERR! node-pre-gyp ERR! stack at ChildProcess. (C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23) npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:517:28) npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1098:16) npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:303:5) npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.25997 npm ERR! node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build" npm ERR! node-pre-gyp ERR! cwd C:\Users\Amit\dev\codevalue\vayyar\VayyarHomeCloud\nodejs-functions\node_modules\libpg-query npm ERR! node-pre-gyp ERR! node -v v18.18.2 npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11 npm ERR! node-pre-gyp ERR! not ok

karlhorky commented 10 months ago

Oh nice, it looks like @lfittl added support for compiling on Windows to libpg_query@16-5.1.0 🎉 🚀

@pyramation @darora would it be possible to get a new release with these changes?

Going to be great to install SafeQL by @Newbie012 for our students with Windows 👍

pyramation commented 10 months ago

I don't have a windows machine to build it, but would be happy to find a way to get this in

karlhorky commented 10 months ago

Could it be built on CI somehow? (eg. GitHub Actions)

Could also be hosted on GitHub Releases maybe, as mentioned by @maschwenk in #35

karlhorky commented 9 months ago

@pyramation or if running the Windows builds in CI is not an option, could a community member with a Windows machine help get this released?

What needs to be done here?

pyramation commented 9 months ago

We're talking about building binaries, so my first question is how can we securely verify it?

Someone that is trusted could manually send a binary over. Then we can publish a new version, and then publish all three together for the new npm version

karlhorky commented 9 months ago

We're talking about building binaries, so my first question is how can we securely verify it?

Good point. There is something in pglast, where @lelit was talking about building Windows binaries here:

Someone that is trusted could manually send a binary over. Then we can publish a new version, and then publish all three together for the new npm version

Ok, makes sense. @lfittl would you or someone on your team be able to build a Windows binary and send it to @pyramation ?

I think that I personally shouldn't be considered as a trusted person yet.

I also asked whether libpg_query would publish binaries on the GitHub releases:

also my telegram is so feel free to ping me there for more sync chat

Nice, I reached out there too, in case we need to do more back and forth.

lelit commented 9 months ago

We're talking about building binaries, so my first question is how can we securely verify it?

Good point. There is something in pglast, where @lelit was talking about building Windows binaries here:

* [Cannot install on windows lelit/pglast#7](https://github.com/lelit/pglast/issues/7)

Someone that is trusted could manually send a binary over. Then we can publish a new version, and then publish all three together for the new npm version

I'm afraid I can be of very little help here, because I'm just a plain end user of nodejs, and I don't know how its packages are built and distributed, but the question above does hold: is it possible to build it on CI and then upload the thing on (say) npmjs.com?

pyramation commented 9 months ago

I'm afraid I can be of very little help here, because I'm just a plain end user of nodejs, and I don't know how its packages are built and distributed, but the question above does hold: is it possible to build it on CI and then upload the thing on (say) npmjs.com?

Yes, we can set that up.

The question I have is ... is it possible to have a CI env that somehow spins up all three operating system environments (windows, osx, and linux) and can get all the output files together before publishing — it may take some wrangling to get it to work

karlhorky commented 9 months ago

is it possible to have a CI env that somehow spins up all three operating system environments (windows, osx, and linux) and can get all the output files together before publishing — it may take some wrangling to get it to work

Should be possible on GitHub Actions, yeah. There are other projects where I've seen GitHub Actions used to automatically build and publish binaries from multiple architectures.

For example:

pyramation commented 8 months ago

is it possible to have a CI env that somehow spins up all three operating system environments (windows, osx, and linux) and can get all the output files together before publishing — it may take some wrangling to get it to work

Should be possible on GitHub Actions, yeah. There are other projects where I've seen GitHub Actions used to automatically build and publish binaries from multiple architectures.

For example:

WOW! thanks @karlhorky — trying something out, stay tuned!

pyramation commented 8 months ago

https://github.com/launchql/libpg-query-node/actions/runs/7984103879/job/21800377394

I started working on a workflow, need to sort out a mac issue — I think it's similar to the M1/docker issue that typically pops up

windows also fails, but at least it's reproducible in CI!

janiu-001 commented 8 months ago

@pyramation any update, do we support windows?

karlhorky commented 7 months ago

@Eprince-hub Looks like Windows support has landed as of libpg-query@16.1.0 🚀

Can you confirm? And if it's working for you, then this issue can be closed?

pyramation commented 7 months ago

closed with #46

Eprince-hub commented 7 months ago

The latest release of the libpg-query now supports Windows; installed successfully in a project on a Windows machine after I installed a fresh Windows 11 on my Windows machine and followed the UpLeveled System Setup Guide

Victor@Victor MINGW64 ~/upleveled/testing-projects/next-js-example-winter-2024-atvie (main)
$ pnpm add libpg-query -D
 WARN  2 deprecated subdependencies found: abab@2.0.6, domexception@4.0.0
Already up to date
Progress: resolved 912, reused 841, downloaded 0, added 0, done

devDependencies:
+ libpg-query 16.1.0

 WARN  Issues with peer dependencies found
.
└─┬ eslint-config-upleveled 7.8.0
  ├── ✕ unmet peer @types/node@>=20.11.17: found 20.11.16
  ├── ✕ unmet peer @types/react@^18.2.55: found 18.2.54
  └── ✕ unmet peer @types/react-dom@^18.2.19: found 18.2.18

Done in 9.6s