Dokku deployment error: You must use Bundler 2 or greater with this lockfile.
When deploying on a dokku server with herokuish
and default buildpacks, If your Ruby on Rails application was bundled with Bundler version 2+, your console might throw the following error You must use Bundler 2 or greater with this lockfile
, resulting in deployment failure. This minipost will demonstrate, how to configure a buildpack for a Ruby on Rails project on a dokku server, that can handle Bundler version 2+ and successfully deploy the application.
Let’s assume that we have an application with the following major dependencies on our Gemfile.lock
:
[..] rails (5.2.2) [..] RUBY VERSION ruby 2.6.1p33 BUNDLED WITH 2.0.1
With the above setup in your Rails application, try to deploy to your dokku server with default buildpacks. The deployment will fail with the following output:
-----> Cleaning up... -----> Building appname from herokuish... -----> Adding BUILD_ENV to build environment... -----> Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. Detected buildpacks: ruby nodejs -----> Ruby app detected ! ! You must use Bundler 2 or greater with this lockfile. !
From the output, please note the warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack that reported to handle this app was unable to. So, you need to install a custom buildpack to handle the above setup.
At , the latest heroku buildpack ruby release that supports the above setup is v199. Connect to your dokku server and configure your application(appname
) to be deployed using the latest buildpack:
dokku config:set --no-restart appname BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-ruby.git#v199
(replace appname
, with your dokku application name)
Finally, push
your code to dokku server:
$ git push dokku master
and get your application successfully deployed.
-----> Fetching custom buildpack -----> Ruby app detected -----> Compiling Ruby/Rails -----> Using Ruby version: ruby-2.6.1 -----> Installing dependencies using bundler 2.0.1 [...] =====> Application deployed: http://www.appname.com https://www.appname.com