Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation fails on windows 10 #60

Closed
Huisong-Li opened this issue Dec 28, 2016 · 14 comments · Fixed by #305
Closed

installation fails on windows 10 #60

Huisong-Li opened this issue Dec 28, 2016 · 14 comments · Fixed by #305

Comments

@Huisong-Li
Copy link

Huisong-Li commented Dec 28, 2016

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)

@lfittl
Copy link
Member

lfittl commented Dec 28, 2016

@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.

@Huisong-Li
Copy link
Author

@lfittl Thank you all the same!
I will try to install libpg_query by myself.
And then install pg_query again.

@lfittl
Copy link
Member

lfittl commented Dec 28, 2016

@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.

@jmbeach
Copy link

jmbeach commented Aug 16, 2017

Same issue.

@MSP-Greg
Copy link

MSP-Greg commented Sep 1, 2017

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...

@vnluc
Copy link

vnluc commented Sep 1, 2017

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.

@Demfier
Copy link

Demfier commented Oct 18, 2017

@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

@MSP-Greg
Copy link

MSP-Greg commented Oct 18, 2017

@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...

@lfittl
Copy link
Member

lfittl commented Oct 18, 2017

@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.

@MSP-Greg
Copy link

@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.

@paulolopesrb
Copy link

Any updates on this? Got the same issue :/

@lfittl
Copy link
Member

lfittl commented Mar 18, 2021

@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.

@spapas
Copy link

spapas commented Sep 14, 2023

Hello, this is a very old issue. I also tried installing it using Ruby+Devkit 3.2.2-1 (x64) on windows 10 and got the following stacktrace:

> gem install pg_query
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing pg_query:
        ERROR: Failed to build gem native extension.

    current directory: C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query
C:/progr/ruby/Ruby32-x64/bin/ruby.exe extconf.rb
creating Makefile

current directory: C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query
make DESTDIR\= sitearchdir\=./.gem.20230914-13188-31zh9e sitelibdir\=./.gem.20230914-13188-31zh9e clean

current directory: C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query
make DESTDIR\= sitearchdir\=./.gem.20230914-13188-31zh9e sitelibdir\=./.gem.20230914-13188-31zh9e
generating pg_query-x64-mingw-ucrt.def
compiling C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/guc-file.c
compiling C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/pg_query.c
In file included from C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/include/c.h:1387,
                 from C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/include/postgres.h:46,
                 from C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/pg_query_internal.h:4,
                 from C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/pg_query.c:2:
C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/include/port.h:24:10: fatal error: port/win32_port.h: No such file or directory
   24 | #include "port/win32_port.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:248: C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3/ext/pg_query/pg_query.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pg_query-4.2.3 for inspection.
Results logged to C:/progr/ruby/Ruby32-x64/lib/ruby/gems/3.2.0/extensions/x64-mingw-ucrt/3.2.0/pg_query-4.2.3/gem_make.out

It seems to be missing a file ?

@lfittl
Copy link
Member

lfittl commented Jan 10, 2024

Windows support has been added in #305 and released as part of 5.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants