我正在自学 Rails。我是一名程序员,但不是网络程序员。我正在阅读迈克尔·哈特尔的书here http://ruby.railstutorial.org/
它提到从一开始就开始部署您的应用程序是个好主意。我同意。所以我在 Heroku 上获得了一个帐户并完成了设置等。然后创建了我的第一个应用程序 git 和作品。然后按照 Heroku 网站上的所有说明进行操作。最后,我使用以下命令将我的应用程序推送到 Heroku:
git push heroku master
书上说,这个阶段可能会出现问题,因为我机器上的应用程序正在使用 sqlite3,而 Heroku 想要 postgresql。
这本书建议将我的应用程序的 gem 文件中的一行更改为
gem 'sqlite3'
to
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 网站的建议here https://devcenter.heroku.com/articles/rails3
更改我的 gemfile
由此:
gem 'sqlite3'
to this:
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
有人可以帮我解决这个问题吗?我遇到了障碍。不知道下一步该做什么。谢谢