Closed Eprince-hub closed 7 months ago
Hi! I don't use windows so would have a hard time testing, reproducing or fixing this. Happy to accept a PR.
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.
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.
Same here, fails to install libpg-query
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.
@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!
Here is the relevant issue, thanks for note @nichita-pasecinic
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:
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!
@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!
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.
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 👍
I don't have a windows machine to build it, but would be happy to find a way to get this in
Could it be built on CI somehow? (eg. GitHub Actions)
Could also be hosted on GitHub Releases maybe, as mentioned by @maschwenk in #35
@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?
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
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.
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?
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
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:
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:
- SWC https://github.com/swc-project/swc/blob/160043a2d3459d7d76758ea46cccdeca5a8c81ca/.github/workflows/CI.yml#L704-756
- sharp https://github.com/lovell/sharp/blob/main/.github/workflows/ci.yml and https://github.com/lovell/sharp/blob/main/.github/workflows/npm.yml
- Playwright https://github.com/microsoft/playwright/blob/5ee7179b13c5302e0d5e3f98019490d70e13aef6/.github/workflows/tests_primary.yml#L228-L265
WOW! thanks @karlhorky — trying something out, stay tuned!
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!
@pyramation any update, do we support windows?
@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?
closed with #46
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
Installing libpg-query on windows 10/11 failed with this long errors below
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
projectcd
into projectinstall
libpg-query