0

When I try to build my app on Heroku, it fails because the Ruby version I purportedly am using is not supported by Heroku. My app has no problem building/deploying locally. Here is full message log:



-----> Ruby app detected

-----> Compiling Ruby/Rails

       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.8.tgz -s -o - | tar zxf - ' failed on attempt 1 of 3.

       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.8.tgz -s -o - | tar zxf - ' failed on attempt 2 of 3.

 !

 !     An error occurred while installing ruby-2.3.8

 !     

 !     This version of Ruby is not available on Heroku-18. The minimum supported version

 !     of Ruby on the Heroku-18 stack can found at:

 !     

 !     https://devcenter.heroku.com/articles/ruby-support#supported-runtimes

 !

 !     Push rejected, failed to compile Ruby app.

 !     Push failed

However, in my Gemfile and Gemfile.lock, I am NOT using ruby-2.3.8. That is why I am very confused. I have links to my Gemfile gist and Gemfile.lock gist.

Things I have tried on Heroku:

Running bundle install.

This. Did not resolve issue, my Gemfile, Gemfile.lock, and local Ruby is ALL 2.6.3.

Making sure Gemfile and Gemfile.lock are the most recent ones in my Github.

Running gem install bundler -v 1.17.3 but it gives me ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /var/lib/gems/2.5.0 directory

EDIT:

It appears after running heroku run ruby -v, that my Ruby version is actually ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

Jessica
  • 1,083
  • 2
  • 12
  • 27
  • This won't likely solve your main issue, but look into using a ruby version manager such as [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io). It looks like you are using your system ruby on your dev machine, and not the same version you are targeting to deploy. A version manager can help developing against several versions of ruby. – Garrett Motzner Jun 19 '19 at 20:42
  • I actually used rbenv to install Ruby on my machine. Doesn't Heroku use the version of Ruby that is specified in my Gemfile though? – Jessica Jun 19 '19 at 20:43
  • the error from `gem install bundler -v 1.17.3` indicates that you aren't using the version of ruby you think you are. It looks like it's trying to use 2.5.0, and it probably isn't the `rbenv` version, because usually you wouldn't get a permissions error with `rbenv`. – Garrett Motzner Jun 19 '19 at 20:46
  • This might help: [Specifying a Ruby Version on Heroku](https://devcenter.heroku.com/articles/ruby-versions) – Garrett Motzner Jun 19 '19 at 20:49
  • All right, thank you for your help. I get off work now but I'll be back tomorrow all day to work on this, and I will check out that link then! :) – Jessica Jun 19 '19 at 20:51

2 Answers2

2

It's possible that the "blessed" version of bundler hasn't been updated yet to 2.0.2, and only 2.0.1 is supported on the official ruby buildpack.

To test this out, you can edit your Gemfile.lock manually and change:

BUNDLED WITH
  2.0.2

to 2.0.1

It will be overridden every time you bundle though, so if that is the fix, you might want to downgrade bundler for the time being.

gwcodes
  • 5,632
  • 1
  • 11
  • 20
  • So I tried that and now my Heroku app SUCCESSFULLY deploys! :D Having some other issues but this is what I needed. Weird as heck though. Thanks! – Jessica Jun 20 '19 at 15:36
  • Yeah, the error you get is weird, but you can see here that `2.0.1` is the current blessed version: https://github.com/heroku/heroku-buildpack-ruby/blob/master/lib/language_pack/helpers/bundler_wrapper.rb#L40. No doubt this'll be updated in time – gwcodes Jun 20 '19 at 15:55
  • Also, what do you mean "blessed"? Never heard that before with code. – Jessica Jun 20 '19 at 17:47
  • What does "blessed" mean? – Jessica Jun 20 '19 at 18:04
  • From reading the code for the build pack, it seems like it only cares about the major version of the lock file. I'm not seeing where it cares if the version stated is newer than the blessed version. However using the blessed version of bundler does seem sensible. I am interested to know though if and why the build pack does care about the exact version. – Garrett Motzner Jun 20 '19 at 18:51
1

On Heroku you cannot configure the version of bundler directly -> https://devcenter.heroku.com/articles/bundler-version#app-not-using-the-currently-supported-bundler-version

I am guessing you are using the heroku buildpack, if not you will want to set that up.

You can switch to a supported buildpack with:

heroku buildpacks:set heroku/ruby

I believe I have had issues where heroku wasn't updating, try the top 2 answers here: Heroku is not updating my code?

One of the pitfalls of heroku is you will need to work with in their construct. I would make sure you are using whatever version of bundler and ruby they want locally prior to deployment and after deployment confirm by sshing on to the heroku box to confirm it is the same version.

Sidenote, using the ruby keyword will only work for certain versions of bundler https://devcenter.heroku.com/articles/ruby-versions#selecting-a-version-of-ruby

I usually set my ruby version in a .ruby-version file in the root of the project.

user3738936
  • 936
  • 8
  • 22
  • My build pack was already set to ```heroku/ruby``` so that is not the problem. It appears the issue is with my Gemfile... :[ – Jessica Jun 20 '19 at 14:58