Ruby on rails ';pg';本地工作,但部署到Heroku时不工作

Ruby on rails ';pg';本地工作,但部署到Heroku时不工作,ruby-on-rails,heroku,bundler,rails-postgresql,pg,Ruby On Rails,Heroku,Bundler,Rails Postgresql,Pg,pg0.18.4在我的开发环境中工作得很好,但在Heroku中不行。在本地,当我刚刚运行bundler安装时,它首先失败了,但当我手动运行gem install pg-v'0.18.4'时,它成功了。我试着配置一个Heroku Postgres插件,但没有成功 当我运行git push heroku master时,我得到以下输出: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. remote:

pg0.18.4
在我的开发环境中工作得很好,但在Heroku中不行。在本地,当我刚刚运行
bundler安装时,它首先失败了,但当我手动运行
gem install pg-v'0.18.4'
时,它成功了。我试着配置一个Heroku Postgres插件,但没有成功

当我运行git push heroku master时,我得到以下输出:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        current directory: /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
remote:        /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/ruby-2.3.0/bin/ruby -r ./siteconf20160123-315-8ytli9.rb extconf.rb --with-pg-config=/usr/pgsql-9.4/bin/pg_config
remote:        Using config values from /usr/pgsql-9.4/bin/pg_config
remote:        sh: 1: /usr/pgsql-9.4/bin/pg_config: not found
remote:        sh: 1: /usr/pgsql-9.4/bin/pg_config: not found
remote:        checking for libpq-fe.h... no
remote:        Can't find the 'libpq-fe.h header
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
remote:        --with-pg
remote:        --without-pg
remote:        --enable-windows-cross
remote:        --disable-windows-cross
remote:        --with-pg-config
remote:        --with-pg-dir
remote:        --without-pg-dir
remote:        --with-pg-include
remote:        --without-pg-include=${pg-dir}/include
remote:        --with-pg-lib
remote:        --without-pg-lib=${pg-dir}/lib
remote:        To see why this extension failed to compile, please check the mkmf.log which can be found here:
remote:        /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/mkmf.log
remote:        extconf failed, exit code 1
remote:        Gem files will remain installed in /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4 for inspection.
remote:        Results logged to /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/gem_make.out
...
Installing tzinfo 1.2.2
remote:        
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
remote:        
remote:        current directory: /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
remote:        /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/ruby-2.3.0/bin/ruby -r ./siteconf20160123-315-8ytli9.rb extconf.rb --with-pg-config=/usr/pgsql-9.4/bin/pg_config
remote:        Using config values from /usr/pgsql-9.4/bin/pg_config
remote:        sh: 1: /usr/pgsql-9.4/bin/pg_config: not found
remote:        sh: 1: /usr/pgsql-9.4/bin/pg_config: not found
remote:        checking for libpq-fe.h... no
remote:        Can't find the 'libpq-fe.h header
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probably lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file for more details.  You may
remote:        need configuration options.
remote:        
remote:        Provided configuration options:
remote:        --with-opt-dir
remote:        --without-opt-dir
remote:        --with-opt-include
remote:        --without-opt-include=${opt-dir}/include
remote:        --with-opt-lib
remote:        --without-opt-lib=${opt-dir}/lib
remote:        --with-make-prog
remote:        --without-make-prog
remote:        --srcdir=.
remote:        --curdir
remote:        --ruby=/tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
remote:        --with-pg
remote:        --without-pg
remote:        --enable-windows-cross
remote:        --disable-windows-cross
remote:        --with-pg-config
remote:        --with-pg-dir
remote:        --without-pg-dir
remote:        --with-pg-include
remote:        --without-pg-include=${pg-dir}/include
remote:        --with-pg-lib
remote:        --without-pg-lib=${pg-dir}/lib
remote:        
remote:        To see why this extension failed to compile, please check the mkmf.log which can be found here:
remote:        
remote:        /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/mkmf.log
remote:        
remote:        extconf failed, exit code 1
remote:        
remote:        Gem files will remain installed in /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4 for inspection.
remote:        Results logged to /tmp/build_a5396c397d6502ad1b8bd59388bde2be/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.18.4/gem_make.out
我的档案:

ruby '2.3.0'
source 'https://rubygems.org'

# Server
gem 'rails', '4.2.5'
gem 'unicorn'
gem 'figaro'

# Database
gem 'bcrypt', '~> 3.1.7'
gem 'paper_trail', '~> 4.0.0'
gem 'pg'
gem 'default_value_for'

# Json
gem 'jbuilder', '~> 2.0'
gem 'oj'
gem 'json-schema'
gem 'responders'

# OAuth
gem 'doorkeeper'

group :production do
  # Heroku
  gem 'rails_12factor'
  # Exceptions
  gem 'exception_notification'
end

group :development do
  # Deployment
  gem 'capistrano', '3.3.3'
  gem 'capistrano-rails'
  gem 'capistrano3-unicorn'
  gem 'capistrano-rvm'
  gem 'capistrano-postgresql'
  gem 'capistrano-safe-deploy-to', '~> 1.1.1'

  # Server
  gem 'spring'

  # Database
  gem 'rails-erd'
end

group :development, :test do
  # Error Pages
  gem 'better_errors'
  gem 'binding_of_caller'

  # Database
  gem 'faker'

  # Debug
  gem 'byebug'

  # Logging
  gem 'lograge'

  # Testing
  # This can't just be in group :test because of https://github.com/rspec/rspec-rails/issues/148
  gem 'rspec-rails'
end

group :test do
  # Database
  # Mocking
  gem 'factory_girl'
  gem 'factory_girl_rails'
  # Cleaning
  gem 'database_cleaner'

  # Code Coverage
  gem 'simplecov', require: false

  # Debug
  gem 'pry-rescue'
  gem 'pry-stack_explorer'

  # Profiling
  # https://github.com/sinisterchipmunk/rspec-prof/issues/10
  gem 'rspec-prof', git: 'https://github.com/sinisterchipmunk/rspec-prof.git'
end

group :doc do
  # RDoc
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '~> 0.4.0', group: :doc
end
更新:Heroku的帮助已经没有了


当我创建并部署一个新的Rails应用程序时(相同的
pg
版本,没有问题。我的行为不端的应用程序中的哪些文件可能会导致这种不同的行为?我正在努力隔离问题,但到目前为止还没有这样的运气。

检查你的。要确保你没有任何问题,请运行
bundle config
并可能运行
bundle remove
。在这种情况下,请尝试
bundle remove build.pg
以防您设置的内容与默认值冲突。

检查您的设置。要确保没有任何内容,请运行
bundle config
并可能运行
bundle remove
。在这种情况下,如果您设置的内容与defa冲突,请尝试
bundle remove build.pg
结果。

有吗?你可以用heroku插件| grep POSTGRES
检查。我刚刚检查了(你给出的命令显示了POSTGRES),但我仍然有相同的错误。奇怪的是,可能是heroku上的构建包错误。试着发出
heroku构建包
,结果是“heroku/ruby”?它没有构建包集。我像文档中所说的那样使用了
heroku create
,除了添加PostgreSQL插件外,没有做任何其他事情。堆栈是
cedar-14
。尝试
heroku构建包:设置heroku/ruby
。这应该没有必要,但不会有任何伤害。然后尝试再次推送您的repo。是吗?您可以检查heroku插件| grep POSTGRES。我刚刚检查了(您给出的命令显示了POSTGRES),但我仍然有相同的错误。奇怪的是,可能是heroku上的buildpack错误。尝试发布heroku buildpack;结果是“heroku/ruby”?它没有构建包集。我使用了文档中所述的
heroku create
,除了添加PostgreSQL插件之外,没有做任何其他事情。堆栈是
cedar-14
。尝试
heroku构建包:设置heroku/ruby
。这应该不是必需的,但不会造成任何伤害。然后再次尝试推送您的repo。