Updating Gemfile.lock on Heroku

abitrolly profile image Anatoli Babenia Updated on ・2 min read


✗ podman run -v "$(pwd)":"/root/app":Z -w "/root/app" -it heroku/heroku:18-build

# gem install bundler --version "~> 1"
# rm Gemfile.lock
# bundle install

If you've got the error message like this.

# bundle install
Your Ruby version is 2.6.5, but your Gemfile specified ~> 2.5.7

Then do.

rm Gemfile.lock
✗ podman run -v "$(pwd)":"/app":Z -w "/app" -it ruby:2.5 bundle install

The Story

Recently I've got a request from my friend to edit information on his website for which the original developer had gone. The web site was written in Ruby on Rails and it was deployed on Heroku using their cedar-14 stack running on Ubuntu 14.

With no experience with Rails or Ruby or Heroku it took almost two weeks to get that app properly backed up and code running on newer heroku-18 base. The first thing I had to do is to update much outdated dependencies in Gemfile.lock to close security bugs and possible glitches on newer OS.

I didn't want to ruin anything, and set the plan to make the copy of the web site both on Heroku newer heroku-18 and on local machine. My local machine is using Fedora, and to avoid configuration drift I did all the work in a Linux container.

Creating a Linux container

Normally I would do everything in LXD container, but because my beautiful hack for sharing project checkouts with remote LXD container over 9p2000 is not ready yet (lack of sponsors and/or time/expertise) I spawned a local container with podman.

NAME=$(basename "$PWD")
podman run -v "$(pwd)":"/root/$NAME":Z -w "/root/$NAME" -it heroku/heroku:18-build

These commands share the directory I am currently in with the newly created container and cd into it when container starts.

I found the reference to heroku:18-build image at https://devcenter.heroku.com/articles/heroku-18-stack#heroku-18-docker-image only few days ago, and at first I used just heroku:18 where I had to spend a day or two to find out and install development libraries, needed to compile and install some gems.

Updating Gemfile.lock

The next problem I spent a day or two was a problem with bundler installer. It is not included in herokiu:18-build image, and I discovered that the latest bundler 2.x doesn't work on Heroku. I found a way to install 1.x.

gem install bundler --version "~> 1"

The rest of it came easy. Remove Gemfile.lock and regenerate it using bundler install.

bundler install


Editor guide