简体   繁体   中英

Installing pg gem on windows crushes

I know that this problem is somehow known but none of posts could help me here. I am trying to install pg gem on Windows 8.1 (got among others: ruby 2.1.7.p400, PostgreSQL 9.5 32bit and devkit 32bit). In a GitBash I put:

$ gem install pg -- --with-pg-include="C:/Program Files (x86)/PostgreSQL/include" --with-pg-lib="C:/Program Files (x86)/PostgreSQL/lib" --with-pg-config="C:/Program Files (x86)/PostgreSQL/9.5/bin/pg_config"

And I get:

Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-pg-include=C:/Program Files (x86)/PostgreSQL/include --with-pg-lib=C:/Program Files (x86)/PostgreSQL/lib --with-pg-config=C:/Program Files (x86)/PostgreSQL/9.5/bin/pg_config'
This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    c:/Ruby217/bin/ruby.exe extconf.rb --with-pg-include=C:/Program Files (x86)/PostgreSQL/include --with-pg-lib=C:/Program Files (x86)/PostgreSQL/lib --with-pg-config=C:/Program Files (x86)/PostgreSQL/9.5/bin/pg_config
Using config values from C:/Program
*** 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:/Ruby217/bin/ruby
        --with-pg
        --without-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
extconf.rb:29:in ``': No such file or directory - "C:/Program" --includedir (Errno::ENOENT) from extconf.rb:29:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in c:/Ruby217/lib/ruby/gems/2.1.0/gems/pg-0.18.4 for inspection.
Results logged to c:/Ruby217/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/pg-0.18.4/gem_make.out

Above is a part of a bigger picture where I tried to push app to heroku:

$ git push heroku master
Counting objects: 10, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.42 KiB | 0 bytes/s, done.
Total 10 (delta 6), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/ruby
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.2-jruby-9.0.0.0
remote: -----> Installing JVM: openjdk-8
remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled properl
y.
remote:        This may result in unexpected gem versions being used in your app
.
remote:        In rare occasions Bundler may not be able to resolve your depende
ncies at all.
remote:        https://devcenter.heroku.com/articles/bundler-windows-gemfile
remote:
remote: -----> Installing dependencies using bundler 1.9.7
remote:        Ruby version change detected. Clearing bundler cache.
remote:        Old: ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-linux]
remote:        New: jruby 9.0.0.0 (2.2.2) 2015-07-22 fffffff OpenJDK 64-Bit Serv
er VM 25.66-b17 on 1.8.0_66-cedar14-b17 +jit [linux-amd64]
remote:        Running: bundle install --without development:test --path vendor/
bundle --binstubs vendor/bundle/bin -j4
remote:        Fetching gem metadata from https://rubygems.org/.............
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Resolving dependencies............
remote:        Installing json 1.8.3
remote:        Installing i18n 0.7.0
remote:        Installing rake 10.5.0
remote:        Installing minitest 5.8.3
remote:        Installing thread_safe 0.3.5
remote:        Installing builder 3.2.2
remote:        Installing rack 1.6.4
remote:        Installing erubis 2.7.0
remote:        Installing arel 6.0.3
remote:        Installing mime-types 2.99
remote:        Using bundler 1.9.7
remote:        Installing coffee-script-source 1.10.0
remote:        Installing jmespath 1.1.3
remote:        Installing nokogiri 1.6.7.1
remote:        Installing execjs 2.6.0
remote:        Installing thor 0.19.1
remote:        Installing concurrent-ruby 1.0.0
remote:        Installing mimemagic 0.3.0
remote:        Installing tilt 2.0.2
remote:        Installing tzinfo 1.2.2
remote:        Installing sass 3.4.21
remote:        Installing rack-test 0.6.3
remote:        Installing mail 2.6.3
remote:        Installing loofah 2.0.3
remote:        Installing coffee-script 2.4.1
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension
.
remote:        /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby-2.2.2-jru
by-9.0.0.0/bin/jruby -r ./siteconf20160119-510-12sshco.rb extconf.rb
remote:        NotImplementedError: C extensions are not supported
remote:        <top> at /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby-
2.2.2-jruby-9.0.0.0/lib/ruby/stdlib/mkmf.rb:1
remote:        require at org/jruby/RubyKernel.java:940
remote:        (root) at /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby
-2.2.2-jruby-9.0.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
remote:        <top> at extconf.rb:2
remote:        extconf failed, exit code 1
remote:        Gem files will remain installed in /tmp/build_750303b177c14834e4a
3ef518ae3807a/vendor/bundle/jruby/2.2.0/gems/pg-0.17.1 for inspection.
remote:        Results logged to /tmp/build_750303b177c14834e4a3ef518ae3807a/ven
dor/bundle/jruby/2.2.0/extensions/universal-java-1.8/2.2.0/pg-0.17.1/gem_make.ou
t
remote:        Installing uglifier 2.7.2
remote:        Installing aws-sdk-core 2.2.11
remote:        Installing sprockets 3.5.2
remote:        Installing rails-html-sanitizer 1.0.2
remote:        Installing activesupport 4.2.5
remote:        Installing tzinfo-data 1.2015.7
remote:        An error occurred while installing pg (0.17.1), and Bundler canno
t continue.
remote:        Make sure that `gem install pg -v '0.17.1'` succeeds before bundl
ing.
remote:        Bundler Output: Fetching gem metadata from https://rubygems.org/.
............
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Resolving dependencies............
remote:        Installing json 1.8.3
remote:        Installing i18n 0.7.0
remote:        Installing rake 10.5.0
remote:        Installing minitest 5.8.3
remote:        Installing thread_safe 0.3.5
remote:        Installing builder 3.2.2
remote:        Installing rack 1.6.4
remote:        Installing erubis 2.7.0
remote:        Installing arel 6.0.3
remote:        Installing mime-types 2.99
remote:        Using bundler 1.9.7
remote:        Installing coffee-script-source 1.10.0
remote:        Installing jmespath 1.1.3
remote:        Installing nokogiri 1.6.7.1
remote:        Installing execjs 2.6.0
remote:        Installing thor 0.19.1
remote:        Installing concurrent-ruby 1.0.0
remote:        Installing mimemagic 0.3.0
remote:        Installing tilt 2.0.2
remote:        Installing tzinfo 1.2.2
remote:        Installing sass 3.4.21
remote:        Installing rack-test 0.6.3
remote:        Installing mail 2.6.3
remote:        Installing loofah 2.0.3
remote:        Installing coffee-script 2.4.1
remote:
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension
.
remote:
remote:        /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby-2.2.2-jru
by-9.0.0.0/bin/jruby -r ./siteconf20160119-510-12sshco.rb extconf.rb
remote:        NotImplementedError: C extensions are not supported
remote:        <top> at /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby-
2.2.2-jruby-9.0.0.0/lib/ruby/stdlib/mkmf.rb:1
remote:        require at org/jruby/RubyKernel.java:940
remote:        (root) at /tmp/build_750303b177c14834e4a3ef518ae3807a/vendor/ruby
-2.2.2-jruby-9.0.0.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
remote:        <top> at extconf.rb:2
remote:
remote:        extconf failed, exit code 1
remote:
remote:        Gem files will remain installed in /tmp/build_750303b177c14834e4a
3ef518ae3807a/vendor/bundle/jruby/2.2.0/gems/pg-0.17.1 for inspection.
remote:        Results logged to /tmp/build_750303b177c14834e4a3ef518ae3807a/ven
dor/bundle/jruby/2.2.0/extensions/universal-java-1.8/2.2.0/pg-0.17.1/gem_make.ou
t
remote:        Installing uglifier 2.7.2
remote:        Installing aws-sdk-core 2.2.11
remote:        Installing sprockets 3.5.2
remote:        Installing rails-html-sanitizer 1.0.2
remote:        Installing activesupport 4.2.5
remote:        Installing tzinfo-data 1.2015.7
remote:        An error occurred while installing pg (0.17.1), and Bundler canno
t continue.
remote:        Make sure that `gem install pg -v '0.17.1'` succeeds before bundl
ing.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:
remote:  !     Push rejected, failed to compile Ruby app
remote:

Thus I tried to install pg -v '0.17.1' or any pg.

I am not sure if that can be the problem but when I started with heroku I used ruby-2.2.2-, engine-jruby-9.0.0.0 and now (while installing pg) I use ruby '2.1.7', :engine => 'ruby', :engine_version => '2.1.7'

Thanks ahead for any inputs!

The current pg gem is buggy and what worked like magic for me is adding this pre version to my gemfile so go to your gem file and add gem 'pg','~>0.19.0.pre20160409114042'

Then run bundle install and It'll work just fine if everything else is ok. If not please tell what's the new mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM