4

I'm having trouble to deploy a rails app to Heroku.

When I tried to push my project to Heroku (git push heroku master), it gave me this error :

Counting objects: 300, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (269/269), done.
Writing objects: 100% (300/300), 255.34 KiB | 6.08 MiB/s, done.
Total 300 (delta 73), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:             Detected buildpacks: Ruby,Node.js
remote:             See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote:        Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.3.5.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3.
remote:        Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.3.5.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3.
remote: 
remote:  !
remote:  !     An error occurred while installing ruby-2.3.5
remote:  !     
remote:  !     This version of Ruby is not available on Heroku-18. The minimum supported version
remote:  !     of Ruby on the Heroku-18 stack can found at:
remote:  !     
remote:  !     https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to agora-challenge.
remote: 
To https://git.heroku.com/agora-challenge.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/agora-challenge.git'

However I changed my ruby version to fit with heroku 18.

I searched here https://devcenter.heroku.com/articles/ruby-support#supported-runtimes for a ruby version that is currently compatible

I installed rvm install "ruby-2.5.3"

I added the line ruby '2.5.3' to the App's Gemfile

I did run bundle install (No Error Messages)

And finally, I did run git push heroku master

Here my Gemfile

source 'https://rubygems.org'
ruby '2.5.3'


gem 'jbuilder', '~> 2.0'
gem 'pg', '~> 0.21'
gem 'puma'
gem 'rails', '5.1.6'
gem 'redis'

gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3'
gem 'font-awesome-sass', '~> 5.0.9'
gem 'sass-rails'
gem 'simple_form'
gem 'uglifier'
gem 'webpacker'
gem 'devise'

group :development do
  gem 'web-console', '>= 3.3.0'
end

group :development, :test do
  gem 'pry-byebug'
  gem 'pry-rails'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'dotenv-rails'
end

I saw this similar question: Having Trouble to deploy a Rails App to Heroku but the answer advised to go to the same link as above...

Thanks!

  • It seems the Ruby version used is not what in your Gemfile. Check: https://stackoverflow.com/questions/1589751/determine-ruby-version-from-within-rails Check also this: https://stackoverflow.com/questions/7777235/rails-not-using-correct-version-of-ruby – iGian Nov 17 '18 at 19:10
  • Did you solve? In case, post the solution, maybe one day I'll need it... – iGian Nov 18 '18 at 18:26
  • Oh yes sorry. But I didn't understand how I solve this issue. I type rvm install ruby-2.5.3. After that when I type in irb RUBY_VERSION, it was noticed the good version "2.5.3". So I tried to push (git push heroku master). Same error: `An error occurred while installing ruby-2.3.5 remote: ! remote: ! This version of Ruby is not available on Heroku-18` So I cleaned my branch (git add . > git commit > git push origin master > git remote -v). Finally, I tried again: git push heroku master. It was work! – clement bacle Nov 19 '18 at 19:39
  • You can downgrade heroku stack to solve this issue. Solution can be found here https://stackoverflow.com/questions/53354444/how-can-i-solve-this-trouble-to-deploy-a-rails-app-to-heroku?answertab=active#tab-top – Dipak Gupta Mar 08 '19 at 09:17

3 Answers3

9

I am posting solution might be late but can help other. Solution most people posting asking to upgrade ruby version. Updating ruby version in an application might be time consuming some time. But with below solution application can deploy without updating ruby version.

Current stack heroku uses is heroku-18, Having image of Ubuntu 18.04. It have minimum supported runtime is ruby 2.4.5, other information here.

To run aplication with below this ruby version you need to downgrade heroku stack for your application.

Open console and run heroku stack you will find.

  cedar-14
  container
  heroku-16
* heroku-18

You need to downgrade to stack which support your ruby version. For ruby 2.3.x you can set heroku-16

heroku stack:set heroku-16

Now if you run heroku stack you will find heroku-16 stack set for your application.

  cedar-14
  container
* heroku-16
  heroku-18

You might get security vulnerability issue on console, Information here.

Try update only sprockets gem to minimum 3.7.2 like:

bundle update sprockets --bundler '3.7.2'

Or you can set :

config.assets.compile = false # Disables security vulnerability

Run git push heroku master. Boom!! Your application deployed successfully.

Dipak Gupta
  • 7,321
  • 1
  • 20
  • 32
0

You should have a .ruby-version file with 2.5.3 in it

Dorian
  • 22,759
  • 8
  • 120
  • 116
0

Please check Ubuntu packages that are installed in each stacks(cedar 14,cedar 16 and cedar 18) in here.

https://devcenter.heroku.com/articles/stack-packages#installed-ubuntu-packages

search for 'ruby' in the list and choose the appropriate cedar stack for the application.

enter image description here

I hope this information can help the others.

zawhtut
  • 8,335
  • 5
  • 52
  • 76