自学rails部署第一个应用程序到heroku -failure上传 - sqlite3和postgre毛刺 [英] teaching myself rails deploying first app to heroku -failure to upload - sqlite3 and postgre glitch

查看:99
本文介绍了自学rails部署第一个应用程序到heroku -failure上传 - sqlite3和postgre毛刺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在教导自己的轨道。我是一名程序员,但不是网络程序员。我正在阅读Michael Hartl的这里

从一开始就开始部署您的应用是一个好主意。我同意。于是我在Heroku上获得了一个帐户,并进行了其他设置,然后创建了我的第一个应用程序,git和这些作品。然后遵循Heroku网站上的所有说明。最后,我使用这个命令来推送我的应用程序到Heroku:

$ g $ push heroku master
本书建议将我应用程序的gem文件中的一行从

  gem'sqlite3'

  gem'sqlite3-ruby',:group => :开发

我试过了,然后运行bundle install然后尝试推送应用程序。没有运气
我在控制台上得到这个消息:
$ b $ pre $ 安装sqlite3(1.3.6)时发生错误,和Bundler无法继续。
确保在捆绑之前,gem install sqlite3 -v'1.3.6'`成功。


!无法通过Bundler安装宝石。

! Heroku推送被拒绝,未能编译Ruby / rails应用程序



因此,我尝试了Heroku网站建议的 here

改变我的gemfile





  gem'sqlite3'

至此:

  gem'pg'

所以我尝试了这种方法,然后运行捆绑安装。但是那也行不通。我在控制台上看到这条消息:

 使用原生扩展安装pg(0.13.2)
Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。

/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
检查pg_config ... no
没有pg_config。无论如何,尝试。如果构建失败,请再次尝试使用
--with-pg-config = / path / to / pg_config
检查libpq-fe.h ... no
无法找到'libpq-fe.h头文件
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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 $ b $ --with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem文件将保持安装在/ Users / AM /.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2进行检查。
结果记录到/Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
安装pg时发生错误(0.13 .2)和Bundler无法继续。
确保在捆绑之前`gem install pg -v'0.13.2'`成功。

尝试运行此命令:

  gem install pg 

失败并显示以下错误消息:

 构建原生扩展。这可能需要一段时间... 
错误:安装pg时出错:
错误:无法构建gem本机扩展。

/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
检查pg_config ... no
没有pg_config。无论如何,尝试。如果构建失败,请再次尝试使用
--with-pg-config = / path / to / pg_config
检查libpq-fe.h ... no
无法找到'libpq-fe.h头文件
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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 $ b $ --with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem文件将保持安装在/ Users / AM /.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2进行检查。
结果记录到/Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out

有人可以帮我解决这个问题。我打了一个障碍。不知道下一步该怎么做。谢谢

解决方案

所以这就是工作原理:
1)在机器上安装postgresql 2)对于永久修复 - 转到.bash_rc文件并添加以下内容:
export PATH =/Library/PostgreSQL/9.1/bin/
:$ PATH

只是为了安装丢失的文件并运行bundle命令一次在应用程序的根目录中输入:
PATH = $ PATH:/Library/PostgreSQL/9.1/ bin / bundle install

PATH = $ PATH:/Library/PostgreSQL/9.1/bin/ gem install pg



3)现在pg宝石已安装



这篇文章很有帮助:
http://excid3.com/blog/installing-postgresql-and-pg-gem-on-mac-osx/


Im teaching myself rails. Im a programmer but not a web programmer. Im going through Michael Hartl's book here

It mentions that its a good idea to start deploying your app right from the beginning. I agree. So I got an account on Heroku and went through ther setup etc. Then created my 1st app, git and the works. Then followed all the instructions on Heroku's site. Finally I came to pushing my app up to Heroku using this command:

git push heroku master

The book says that there could be problems at this stage because the app on my machine is using sqlite3 while Heroku wants postgresql. The book suggests changing a line in the gem file of my app from

gem 'sqlite3'

to

gem 'sqlite3-ruby', :group => :development

I tried that and then ran bundle install and then tried to push the app. No luck I get this message on my console:

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.

! ! Failed to install gems via Bundler. ! ! Heroku push rejected, failed to compile Ruby/rails app

So I tried what the Heroku website suggests here

to change my gemfile

from this:

gem 'sqlite3'

to this:

gem 'pg'

so I tried this approach and then ran 'bundle install'. But that didn't work either. I get this message on my console:

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.

Tried to run this command:

gem install pg

that failed with the following error message:

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

Can someone please help me with this. ive hit a roadblock. Not sure what to do next.Thanks

解决方案

So this is what worked: 1) Install postgresql on the machine

2) For permanent fix - Go to the .bash_rc file and add the following: export PATH = "/Library/PostgreSQL/9.1/bin/":$PATH OR just to install the missing files and run the bundle command one time type this in the root of the app: PATH=$PATH:/Library/PostgreSQL/9.1/bin/ bundle install or PATH=$PATH:/Library/PostgreSQL/9.1/bin/ gem install pg

3) Now the pg gem is installed

This post was helpful: http://excid3.com/blog/installing-postgresql-and-pg-gem-on-mac-osx/

这篇关于自学rails部署第一个应用程序到heroku -failure上传 - sqlite3和postgre毛刺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆