Rails 在heroku上部署rails时出错,谁有经验分享一下。。

mayday · 发布于 2012年10月12日 · 最后由 bestar 回复于 2015年12月19日 · 7700 次阅读
3974

git push heroku master

Counting objects: 63, done. Delta compression using up to 4 threads. Compressing objects: 100% (49/49), done. Writing objects: 100% (63/63), 25.95 KiB, done. Total 63 (delta 2), reused 0 (delta 0)

-----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.2.1 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment Fetching gem metadata from https://rubygems.org/....... Installing rake (0.9.2.2) Installing i18n (0.6.1) Installing multi_json (1.3.6) Installing activesupport (3.2.8) Installing builder (3.0.3) Installing activemodel (3.2.8) Installing erubis (2.7.0) Installing journey (1.0.4) Installing rack (1.4.1) Installing rack-cache (1.2) Installing rack-test (0.6.2) Installing hike (1.2.1) Installing tilt (1.3.3) Installing sprockets (2.1.3) Installing actionpack (3.2.8) Installing mime-types (1.19) Installing polyglot (0.3.3) Installing treetop (1.4.11) Installing mail (2.4.4) Installing actionmailer (3.2.8) Installing arel (3.0.2) Installing tzinfo (0.3.33) Installing activerecord (3.2.8) Installing activeresource (3.2.8) Installing coffee-script-source (1.3.3) Installing execjs (1.4.0) Installing coffee-script (2.2.0) Installing rack-ssl (1.3.2) Installing json (1.7.5) with native extensions Installing rdoc (3.12) Installing thor (0.16.0) Installing railties (3.2.8) Installing coffee-rails (3.2.2) Installing jquery-rails (2.1.3) Using bundler (1.2.1) Installing rails (3.2.8) Installing sass (3.2.1) Installing sass-rails (3.2.5) Installing sqlite3 (1.3.6) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite-devel' and check your shared library search path (the location where your sqlite3 shared library is located). *** 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=/usr/local/bin/ruby --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib --enable-local --disable-local Gem files will remain installed in /tmp/build_30ry2j1dmqe1y/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection. Results logged to /tmp/build_30ry2j1dmqe1y/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out An error occurred 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. !
! Detected sqlite3 gem which is not supported on Heroku. ! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development ! ! Heroku push rejected, failed to compile Ruby/rails app

To git@heroku.com:peaceful-journey-4004.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:peaceful-journey-4004.git'

共收到 16 条回复
3974

看到这个方法:1、找到项目的gemfile文件,打开之后,修改gem sqlite3为:

gem 'sqlite3', :group => [:development, :test] group :production do gem 'thin' gem 'pg' end

2、删除掉gemfile.lock文件 3、运行 `bundle install --without production 4、运行git add . 5、运行git commit -m "bundle updating sqlite3" 6、运行git push heroku master

但依旧出错...

96

试试

group :development, :test do
  gem "sqlite3-ruby", :require => "sqlite3"
end

EDIT: SO连接http://stackoverflow.com/questions/3747002/heroku-rails-3-and-sqlite3

3333

heroku,在部署的时候数据库得用pg。

2650

第二次错误是什么

3807

o同意3楼的观点,

2650

#5楼 @menghuanwd #3楼 @xiaolai

gem 'sqlite3', :group => [:development, :test]

group :production do
  gem 'thin'
  gem 'pg'
end

看他这段代码的话,已经写了pg了。 貌似应该是别的错误

96
gem 'sqlite3', :group => [:development, :test]
3974

@blueplanet @menghuanwd -----> Installing dependencies using Bundler version 1.2.1 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment You are trying to install in deployment mode after changing your Gemfile. Run bundle install elsewhere and add the updated Gemfile.lock to version control. You have added to the Gemfile: * thin * pg ! ! Failed to install gems via Bundler. ! ! Heroku push rejected, failed to compile Ruby/rails app

2650

不应该把gemfile.lock删掉,而是应该把它加到git里,并push到Heroku上去

1477

我之前也遇到过和LZ一样的问题,不过时间有点长了 太具体不知道怎么回答,不过相信这个可以解决你的问题http://railsapps.github.com/rails-heroku-tutorial.html

3807

#10楼 @robin 你给的教程我试了下,在执行heroku run rake db:migrate的时候,出现: G:\rubyandrailsproject\onkerokutest>heroku run rake db:migrate ! Heroku client internal error. ! Search for help at: https://help.heroku.com ! Or report a bug at: https://github.com/heroku/heroku/issues/new

Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed becau se connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT) Backtrace: G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/client/rendezvous.rb:36:in initialize' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/client/rendezvous.rb:36:inopen' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/client/rendezvous.rb:36:in block in start' G:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/timeout.rb:68:inti meout' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/client/rendezvous.rb:30:in start' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/command/run.rb:125:inrendezvous_session' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/command/run.rb:112:in run_attached' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/command/run.rb:21:inindex' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/command.rb:206:in run' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/lib/heroku/cli.rb:28:instart' G:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/heroku-2.3 1.4/bin/heroku:16:in <top (required)>' G:/RailsInstaller/Ruby1.9.3/bin/heroku:19:inload' G:/RailsInstaller/Ruby1.9.3/bin/heroku:19:in `

'

Command: heroku run rake db:migrate Version: heroku-toolbelt/2.31.4 (i386-mingw32) ruby/1.9.3

然后页面上只显示:We're sorry, but something went wrong...求解答

861

heroku有教程的吧。当初我刚刚部署也是问题一大堆,看它提供的教程解决的。

1477

#11楼 @menghuanwd https://github.com/heroku/heroku/issues/378 check this one 看到有人是因为路由问题造成了和你一样的问题显示 话说LZ用windows? 唔。。。

96

rails新手,我折腾的比较顺利,可参考:http://ruby-china.org/topics/6286

17285

我也遇到了一样的问题,刚刚解决了。 gem 'sqlite3', '1.3.9' 如果有类似的语句,请务必放在 group :development, :test do 里面。 #Ruby China 欢迎回复这种老帖子吗?如有不妥请告知,我也是刚才遇到了这个问题才搜索到的这个老帖。

24096

15楼正解,按照他的方法我也解决了这个问题。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册