problem deploying ruby on rails app to Heroku: ruby version issue - ruby-on-rails

I forked and cloned a repo so I could deploy to Heroku - then I got the message below asking to upgrade the project Ruby version.
! The Ruby version you are trying to install does not exist on this stack.
!
! You are trying to install ruby-2.7.4 on heroku-22.
!
! Ruby ruby-2.7.4 is present on the following stacks:
!
! - heroku-18
! - heroku-20
!
! Heroku recommends you use the latest supported Ruby version listed here:
! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
!
! For more information on syntax for declaring a Ruby version see:
! https://devcenter.heroku.com/articles/ruby-versions
!
! Push rejected, failed to compile Ruby app.
! Push failed
In my Mac when I run ruby -v I get 3.1.2 version. When I go into the project's Gemfile and type the old version to the latest, I run bundle install but I get this message:
rbenv: version `2.7.4' is not installed (set by /Users/luciamoral/code/Luciamoral/Driven-App/.ruby-version)
Does this mean I need to also install the oldest version so it works? Also, I found that it is not recording changes when I push to origin master, despite having forked and cloned it to my machine. Any ideas please? Thanks!

You have the Ruby version specified in two places, .ruby-version and Gemfile. Only use one. Heroku only cares about the Gemfile.
Your options are to either downgrade to a version of the heroku stack which supports your version of Ruby, which just pushes off the problem, or upgrade your Ruby version.

Related

This version of Ruby is not available on Heroku-18

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]
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.
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.

[Trying to Deploy]: You must use Bundler 2 or greater with this lockfile

Very new to Ruby and Ruby on Rails, so apologies in advance. I've found many similar posts to this, but the suggestions haven't worked for me so far.
I get that the Bundler version I'm using doesn't match with the of Heroku when I try to deploy, but can't get them to match.
I tried this and it looked like it would work, but no luck. You must use Bundler 2 or greater with this lockfile
Does anyone have any ideas, or can you tell me what information you require to give some assistance?
Many thanks!
Remove your Gemfile.lock
Install old version of bundler, for example
gem install bundler -v 1.17.3
Run this bundler in your project directory
bundle _1.17.3_ install
Make any commit, for example
git commit -am "Bundler 1.17.3 was installed"
Run
git push heroku master
Smile
I had this issue as well trying to push to my Heroku project. Found the answer in another question and it worked for me: You must use Bundler 2 or greater with this lockfile
run: heroku buildpacks:set https://github.com/bundler/heroku-buildpack-bundler2
Then try push your app again.
I struggled with this and after seeing another comment, I realized that when I upgraded the latest version of Ruby that it was not compatible with Bundler. I uninstalled Ruby, installed Ruby 2.4.5-1 and reinstalled my gems (including Rails). I can now get on Rails and no more Bundler error.

Heroku RoR project deployment : An error occurred while installing ruby-1.9.3-p551

I am trying to deploy Ruby on Rails project with Ruby-1.9.3-p551 version but it fails on installing Ruby 1.9.3 version giving the error below:
! An error occurred while installing ruby-1.9.3-p551
!
! Heroku recommends you use the latest supported Ruby version listed here:
! https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
!
! For more information on syntax for declaring a Ruby version see:
! https://devcenter.heroku.com/articles/ruby-versions
Specifically you have to tell heroku to give you the ubuntu server build with cedar-14 & then ensure the gemfile is reflected in the gemfile.lock
Details on here ... Errors in Gemfile
This page contains details on what you need ... https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
Ruby 1.9.1 reached EOL many years ago, and is not supported by Heroku anymore.
You should upgrade your ruby version.

Cannot push to heroku - bundler fails

I'm trying to push my rails project to heroku bit when doing a git push heroku master bundler fails with the following message:
Bundler Output: Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Fetching git://github.com/justinfrench/formtastic.git
Fetching git://github.com/activerecord-hackery/ransack.git
Fetching git://github.com/gregbell/active_admin.git
Could not find jwt-0.1.12 in any of the sources
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:murmuring-mountain-9361.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:murmuring-mountain-9361.git'
It seems jwt is a dependency of one of my gems, but it installs fine on my local environment. I tried explicitly declaring gem 'jwt', '0.1.12' in my gemfile, which worked fine locally, but not on heroku and I tried deleting the Gemfile.lock and generating it again. I even tried deleting the app instance off heroku and creating it again.
The following gist is my gemfile: https://gist.github.com/anonymous/84d3fc00566e036729cd
I'm using this vagrant box for my dev environment: https://github.com/ejholmes/vagrant-heroku
If you updated your gems in the last few days then you would have gotten a faulty version that was yanked. It was re-released as 1.0.0 because it has a slightly different API. I'd recommend using 0.1.11 or switching to 1.0 ... thanks, and sorry!
You'll get this when versions of Gems you are using (via your Gemfile.lock) have been yanked from RubyGems.org and Heroku is trying to grab them when you deploy.
You can see that 0.1.12 of jwt has been yanked at http://rubygems.org/gems/jwt/versions. The thing to do would be to look at your Gemfile.lock to see which gem is declaring the dependency on 0.1.12 and then fork that gem and bump the version and then use your forked version. Or contact the Gem owner and gem them to bump the dependency.

Trouble pushing barebones app to Heroku with paperclip gem

We have an app that's been running on Heroku (bamboo) for over a year. When pushing a change yesterday, the push was rejected when it failed to install the paperclip gem. No changes had been made to the gem list up to the point of failure. I tried a brand new, barebones app and got the same result. It seems the bamboo stack has changed in some way. Anybody else experiencing this or know what might be going on?
Here are repro steps:
$ rails temp-app
$ cd temp-app
$ cat >.gems
rails -v 2.3.14
paperclip -v 2.5.0
<control-D>
$ git init
$ git add .
$ git commit -m "init"
$ heroku create --stack bamboo
$ git push heroku master
this is the output:
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Installing gem rails 2.3.14 from http://rubygems.org
Successfully installed activesupport-2.3.14
Successfully installed activerecord-2.3.14
Successfully installed actionpack-2.3.14
Successfully installed actionmailer-2.3.14
Successfully installed activeresource-2.3.14
Successfully installed rails-2.3.14
6 gems installed
-----> Installing gem paperclip 2.5.0 from http://rubygems.org
ERROR: While executing gem ... (NoMethodError)
undefined method `call' for nil:NilClass
! Heroku push rejected, failed to install gem
I did get an answer from Heroku support: Paperclip specifies a dependency on Active Record like this: 'activerecord', '>= 2.3.0' which causes the latest AR version to be installed. The latest version as of a few days ago is 3.2, which is broken on Rails 2.3, hence the failure.
I solved this by adding --ignore-dependencies to the paperclip gem in .gems and manually adding dependencies to .gems.

Resources