Heroku push rejected - Hartl's Rails 3.2 tutorial

走远了吗. 提交于 2020-01-15 04:59:28

问题


I am a ruby, ruby on rails and heroku greenhorn, which is trying to learn to code from Michael Hartl's Ruby on Rails 3.2 tutorial.

Now at the very beginning of this chapter I failed to deployed all to Heroku. This error message I got (but I have no plan what to do to solve this problem):

$ git push heroku master
Counting objects: 69, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (54/54), done.
Writing objects: 100% (69/69), 27.34 KiB, done.
Total 69 (delta 5), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/
       Fetching gem metadata from https://rubygems.org/........
       Bundler could not find compatible versions for gem "railties": 
       In Gemfile: 
       rails (= 3.2.6) ruby depends on 
       railties (= 3.2.6) ruby 
       jquery-rails (= 2.0.0) ruby depends on 
       railties (3.2.7.rc1) 

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

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

My Gemfile looks like this:

source 'https://rubygems.org'

gem 'rails', '3.2.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0' 
end



# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.0'

group :test do
  gem 'capybara', '1.1.2'
end

group :production do
  gem 'pg', '0.12.2'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

I hope someone could help me out (sorry, I am a beginner --> also at Stackoverflow, lol). KR, Fabian


回答1:


The default generated Gemfile (with rails 3.2.6) does not specify a jquery-rails version to use. I would recommend doing the same, like so:

# remove version number, just like you would see in a fresh rails app
gem 'jquery-rails' 

The version you have required, 2.0.0, relies on railties 3.2.7.rc1 gem, which you can't use with rails 3.2.6.

I used your code in my app, and couldn't get it to bundle on my local host. This makes me wonder if you tried that too yourself before pushing to heroku. You should always bundle install on your local machine first.

Also, you appear to have bumped the required version numbers of sass-rails and coffee-rails. Here's what you'd expect in a clean rails app's Gemfile:

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'



回答2:


I could now solve the problem by myself. This was the way:

  1. Go to Gemfile and change the section with gem 'rails', '3.2.6' to gem 'rails', '3.2.7rc1'.
  2. save
  3. run bundle install --without production
  4. run git add .
  5. commit to git like git commit -a -m "Heroku recommit
  6. push to github like git push and follow the instruction for username and password
  7. and last git push heroku master

Wow, this was hard, but very educational :-)




回答3:


The problem is the jquery-rails gem needs a different version of railties than the rails gem in your bundle file. You can try to remove the "2.0.0" from jquery-rails and try again. Bundle will install a version of the gem which works wit version 3.2.6 of railties.



来源:https://stackoverflow.com/questions/11668675/heroku-push-rejected-hartls-rails-3-2-tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!