Ruby on rails gem pg和#x27;libpq fe.h收割台';和Heroku推送错误

Ruby on rails gem pg和#x27;libpq fe.h收割台';和Heroku推送错误,ruby-on-rails,ruby,heroku,rubygems,Ruby On Rails,Ruby,Heroku,Rubygems,我根据教程创建了(通过railsnew)三个看起来完全相同的rails应用程序。前两个可以通过rails服务器本地启动或heroku open启动,没有任何问题。第三个也通过railsnew生成,可以在本地启动(通过railsserver),但不能通过heroku open启动。经过大量阅读,我得出结论,这与gem的“pg”有关,但为什么其他两个应用程序不存在这个问题呢?我甚至复制了其中一个“成功”应用程序的Gemfile,看看是否可以让第三个应用程序在Heroku上运行(no go)。非常感谢

我根据教程创建了(通过
railsnew
)三个看起来完全相同的rails应用程序。前两个可以通过
rails服务器
本地启动或
heroku open
启动,没有任何问题。第三个也通过
railsnew
生成,可以在本地启动(通过
railsserver
),但不能通过
heroku open
启动。经过大量阅读,我得出结论,这与gem的“pg”有关,但为什么其他两个应用程序不存在这个问题呢?我甚至复制了其中一个“成功”应用程序的Gemfile,看看是否可以让第三个应用程序在Heroku上运行(no go)。非常感谢您的任何见解

下面是
捆绑安装
结果:

Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.1.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.1
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.4
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.2.1
Using rack 2.0.5
Using rack-test 1.1.0
Using actionpack 5.2.1
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using websocket-driver 0.7.0
Using actioncable 5.2.1
Using globalid 0.4.1
Using activejob 5.2.1
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.2.1
Using activemodel 5.2.1
Using arel 9.0.0
Using activerecord 5.2.1
Using mimemagic 0.3.2
Using marcel 0.3.2
Using activestorage 5.2.1
Using public_suffix 3.0.2
Using addressable 2.5.2
Using io-like 0.3.0
Using archive-zip 0.11.0
Using execjs 2.7.0
Using autoprefixer-rails 9.1.0
Using coderay 1.1.2
Using better_errors 2.4.0
Using bindex 0.5.0
Using msgpack 1.2.4
Using bootsnap 1.3.1
Using rb-fsevent 0.10.3
Using ffi 1.9.25
Using rb-inotify 0.9.10
Using sass-listen 4.0.0
Using sass 3.5.7
Using bootstrap-sass 3.3.7
Using bundler 1.16.3
Using byebug 10.0.2
Using xpath 3.1.0
Using capybara 3.5.1
Using childprocess 0.9.0
Using chromedriver-helper 1.2.0
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.2.1
Using coffee-rails 4.2.2
Using multipart-post 2.0.0
Using faraday 0.15.2
Using multi_json 1.13.1
Using gibbon 3.2.0
Using high_voltage 3.1.0
Using jbuilder 2.7.0
Using jquery-rails 4.3.3
Using ruby_dep 1.5.0
Using listen 3.1.5
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using rails 5.2.1
Using minitest-spec-rails 5.4.0
Fetching pg 0.20.0
Installing pg 0.20.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/new-laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-0.20.0/ext
/Users/new-laptop/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180808-7108-inkyrf.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/Users/new-laptop/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/new-laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/pg-0.20.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/new-laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-0.20.0 for inspection.
Results logged to /Users/new-laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/pg-0.20.0/gem_make.out

An error occurred while installing pg (0.20.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.20.0' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  pg
下面是
mkmf.log
log:

New-Laptop:toy_app new-laptop$ cat  /Users/new-laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/pg-0.20.0/mkmf.log
find_executable: checking for pg_config... -------------------- no

--------------------

find_header: checking for libpq-fe.h... -------------------- no

"clang -o conftest -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/Users/new-laptop/.rbenv/versions/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/new-laptop/.rbenv/versions/2.5.1/lib -L. -L/Users/new-laptop/.rbenv/versions/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -E -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/new-laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/Users/new-laptop/.rbenv/versions/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe  conftest.c -o conftest.i"
conftest.c:3:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^~~~~~~~~~~~
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libpq-fe.h>
/* end */
New Laptop:toy_app New Laptop$cat/Users/New Laptop/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/pg-0.20.0/mkmf.log
查找\u可执行文件:正在检查pg\u配置…------------不
--------------------
find_头:检查libpq fe.h..-------不
“clang-o conftest-I/Users/new laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86\u 64-darwin17-I/Users/new laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward-I/Users/new laptop/.rbenv/versions/2.5.1/include-D XOPEN-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-D-DY-ReCuNut-O3-WNO错误=Stutto-64-to 32管ButTest.CL-L/用户/新笔记本/ .RbEnV/Value/2.5.1/LIB -L.L/用户/新笔记本/ .RbEnV/Value/2.5.1/LIB -F堆栈保护器-L/USR/Studio/LIB -LURBY .2.5.1-静态-框架基础-LpTrim-LDL -ROBJC
检查的程序是:
/*开始*/
1:#包括“ruby.h”
2: 
3:int main(int argc,字符**argv)
4: {
5:返回0;
6: }
/*结束*/
“clang-E-I/Users/new laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17-I/Users/new laptop/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward-I/Users/new laptop/.rbenv/versions/2.5.5.1/tr-D\XOPEN\u-SOURCE-D\u\u达尔文选择源代码ANT-O3-Wno错误=shorten-64-to-32-pipe conftest.c-o conftest.i“
conftest.c:3:10:致命错误:“未找到libpq fe.h”文件
#包括
^~~~~~~~~~~~
生成1个错误。
检查的程序是:
/*开始*/
1:#包括“ruby.h”
2: 
3:#包括
/*结束*/

您的计算机上似乎没有安装PostgreSQL。首先安装PostgreSQL(例如通过自制):

然后再次捆绑:

bundle install

您的计算机上似乎没有安装PostgreSQL。首先安装PostgreSQL(例如通过自制):

然后再次捆绑:

bundle install

如果您正在使用Postgres.app运行dbs,请参阅

gem安装pg--with pg config=/Applications/Postgres.app/Contents/Versions/my version/bin/pg\u config


如果您正在使用Postgres.app运行dbs,请参阅

gem安装pg--with pg config=/Applications/Postgres.app/Contents/Versions/my version/bin/pg\u config


可能pg版本旧了,尝试使用1.0.0版本<代码>gem'pg'然后
捆绑更新
可能是pg版本旧了,尝试使用1.0.0版本
gem'pg'
那么
bundle update
Postgresql没有安装——它会导致sqlite出现问题吗?另外:我问这个问题的原因是:为什么其他应用程序可以工作而不是这个应用程序?这个应用程序显然取决于需要在您的机器上安装Postgresql的
pg
gem。或者至少
pg
gem在您的gem文件中。它会导致SQLite出现问题吗?不,两者在同一台机器上都能正常工作。为什么其他应用程序没有PostgreSQL就可以工作?他们可能对GEM文件中定义的
pg
没有依赖关系。“依赖关系”是我需要理解的部分。现在我知道该调查什么了。非常感谢。Postgresql没有安装——它会导致sqlite出现问题吗?另外:我问这个问题的原因是:为什么其他应用程序可以工作而不是这个?这个应用程序显然取决于需要在您的机器上安装Postgresql的
pg
gem。或者至少
pg
gem在您的gem文件中。它会导致SQLite出现问题吗?不,两者在同一台机器上都能正常工作。为什么其他应用程序没有PostgreSQL就可以工作?他们可能对GEM文件中定义的
pg
没有依赖关系。“依赖关系”是我需要理解的部分。现在我知道该调查什么了。非常感谢。我试过这一个,我得到了我需要的版本,1.2.3的pg,但文件夹不包含我需要的所有文件。它似乎不完整。我正在使用Win10。这个问题有什么解决办法吗,谢谢。我试过这个,我得到了我需要的版本,1.2.3的pg,但是文件夹中没有包含我需要的所有文件。它似乎不完整。我正在使用Win10。请问这个问题有什么解决办法吗?谢谢。