我自学rails。我是程序员,但不是网络程序员。我在这里浏览迈克尔哈特尔的书
它提到从一开始就开始部署您的应用程序是一个好主意。我同意。所以我在 Heroku 上获得了一个帐户并进行了设置等。然后创建了我的第一个应用程序 git 和作品。然后按照 Heroku 网站上的所有说明进行操作。最后,我开始使用以下命令将我的应用程序推送到 Heroku:
git push heroku master
这本书说在这个阶段可能会出现问题,因为我机器上的应用程序使用的是 sqlite3 而 Heroku 需要 postgresql。这本书建议在我的应用程序的 gem 文件中更改一行
gem 'sqlite3'
到
gem 'sqlite3-ruby', :group => :development
我试过了,然后运行捆绑安装,然后尝试推送应用程序。不幸的是,我在控制台上收到了这条消息:
An error occured while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
!!无法通过 Bundler 安装 gem。!!Heroku 推送被拒绝,无法编译 Ruby/rails 应用程序
所以我尝试了 Heroku 网站在这里的建议
更改我的 gemfile
由此:
gem 'sqlite3'
对此:
gem 'pg'
所以我尝试了这种方法,然后运行“捆绑安装”。但这也没有用。我在控制台上收到此消息:
Installing pg (0.13.2) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby 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
--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/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.
尝试运行此命令:
gem install pg
失败并显示以下错误消息:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby 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
--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/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
Gem files will remain installed in /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
有人可以帮我解决这个问题。我遇到了障碍。不知道下一步该怎么做。谢谢