pg_query
pg_query copied to clipboard
installation fails on windows 10
when i first time tried to install pg_query i failed it reminded me to install DevKit i installed it then test installtion as follow https://github.com/oneclick/rubyinstaller/wiki/Development-Kit#5-test-installation DevKit works well and i tried again to install pg_query, it reminded me as follow:
C:\Users\GL3\Desktop>gem install pg_query
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing pg_query:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby23/lib/ruby/gems/2.3.0/gems/pg_query-0.11.3/ext/pg_query
C:/Ruby23/bin/ruby.exe -r ./siteconf20161228-10592-e86sbx.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby23/bin/$(RUBY_BASE_NAME)
C:/Ruby23/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)
from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:933:in `connect'
from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from C:/Ruby23/lib/ruby/2.3.0/net/http.rb:852:in `start'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:319:in `open_http'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:737:in `buffer_open'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:212:in `block in open_loop'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:210:in `catch'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:210:in `open_loop'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:151:in `open_uri'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:717:in `open'
from C:/Ruby23/lib/ruby/2.3.0/open-uri.rb:35:in `open'
from extconf.rb:15:in `block in <main>'
from extconf.rb:14:in `open'
from extconf.rb:14:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby23/lib/ruby/gems/2.3.0/gems/pg_query-0.11.3 for inspection.
Results logged to C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/pg_query-0.11.3/gem_make.out
i work on windows 10 amd 64 ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] i installed all dependce from https://rubygems.org/gems/pg_query/versions/0.9.2 no matter runtime or devlopment and i also installed postgresql 9.6 (X86)
@Huisong-Li Thanks for trying out pg_query!
It seems your client fails to verify the certificate when downloading https://codeload.github.com/lfittl/libpg_query/tar.gz/9.5-1.4.2
- this might be due to Ruby on Windows not having a proper list of trusted certificate authorities (CA).
I'm unfortunately not familiar with Ruby on Windows, so can't really advise as to why this is failing.
@lfittl Thank you all the same! I will try to install libpg_query by myself. And then install pg_query again.
@Huisong-Li Unfortunately the way the gem works, you can't really setup the C library independently right now.
If you can't get the CA certificate issue to work, it might be easiest to fork the gem and adjust the extconf.rb file to accept invalid certificates.
I might also resolve this in a future release by taking an approach similar to the Go library, which already includes a copy of the C library.
Same issue.
I believe the issue is in extconf.rb
workdir = Dir.pwd
...
system("tar -xf #{workdir}/libpg_query.tar.gz")
Using windows, Dir.pwd
will return something like E:/
, so there's probably a 'double' forward slash. Also, it seems the tar exe in MSYS2 won't take a window's drive style, so it needs to convert E:/
to /e
.
IOW, I tried
E:\>tar -xf E:/libpg_query.tar.gz
and it didn't work.
E:\>tar -xf /e/libpg_query.tar.gz
worked fine. Hope this helps...
Thank you @MSP-Greg , I did change the extconf.rb file and it does pass to generate makefile.
I try make install for this gem. it got new error
D:\ruby\ruby_packages_nobk\rubyinstaller-2.5.0-snapshot-x64_aug29\lib\ruby\gems\2.5.0\gems\pg_query- 0.13.2>make install generating pg_query-x64-mingw32.def compiling ./ext/pg_query/pg_query_ruby.c linking shared-object pg_query/pg_query.so D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpg_query collect2.exe: error: ld returned 1 exit status make: *** [Makefile:259: pg_query.so] Error 1
Seems it require some lpg_query, I am trying figuring out.
@Huisong-Li I too got the same issue as you but on Ubuntu. Figured out, it was due to my network being behind a proxy. I set the HTTP_PROXY
variable in .bashrc
and it worked.
cc @lfittl
@lfittl
Thought I'd take a look at at this re Windows. Made some changes here and there. I'm now stopped at
./src/postgres/include/port.h:17:10: fatal error: netdb.h: No such file or directory
#include <netdb.h>
^~~~~~~~~
compilation terminated.
Can't seem to find netdb.h
in the gem or libpg_query-9.5-1.6.2. Re MinGW installs, I found this in some windows / MinGW library code
+#ifdef __MINGW64_VERSION_MAJOR
+#include <winsock2.h>
+#else
#include <netdb.h>
+#endif
Just forked libpg_query
. I doubt it can easily be ported to work on Windows. Just came across pwd.h
. Hence, never mind, and thanks...
@MSP-Greg Hmm, I suspect we'd need to teach the extraction logic in libpg_query about considering Windows, and keeping the Windows code parts of Postgres intact.
Since I don't have access to a Windows system this makes it a bit difficult for me to help on this, but if someone wanted to work on this, I would recommend looking into setting up LLVM + Ruby bindings, and then modifying the extract_source.rb script in libpg_query to do the right thing.
We might also need to have some more of these defines set on Windows, since we don't have ./configure
running, as Postgres would usually have to figure out whats supported.
All in all this is not an easy task, as you say.
@lfittl
I did look at the extraction logic.
Haven't stated it anywhere here, I'm a ruby coder & I build a lot of ruby code (and 'extension' gems) on windows. But, critical issue, I don't know c. I can read it and get a general idea, but that's about it.
IOW, even if I had the time... Thanks.
Any updates on this? Got the same issue :/
@paulolopesrb No updates yet - Windows support is a known limitation right now.
I've tried to get this into the new 2.0 release, but ultimately ended up not making it because of time constraints. This is still on my list though, and I hope to get to it in the next months.
Contributions are welcome, but they'd need to be made in libpg_query directly - if you can figure out the necessary header changes (like discussed a bit above), that would make my life a lot easier, and enable me to fix this faster.