Search code examples
ruby-on-railsrubypuma

NameError: uninitialized constant Capistrano::Puma


I got NameError: uninitialized constant Capistrano::Puma with this Gemfile:

source "https://rubygems.org"

ruby "2.7.1"

gem "rails"
gem "pg"
gem "puma"
gem "webpacker"
gem "jbuilder"
gem "bcrypt"
gem "slim-rails"
gem "emoji_regex"
gem "dotenv-rails"

gem "bootsnap", require: false

group :development, :test do
  gem "byebug"
end

group :development do
  gem "web-console"
  gem "listen"
  gem "spring"
  gem "spring-watcher-listen"

  gem "capistrano"
  gem "capistrano-rails"
  gem "capistrano-rbenv"
  gem "capistrano3-puma", "4.0.0"
end

group :test do
  gem "capybara"
  gem "selenium-webdriver"
  gem "webdrivers"
  gem "shoulda-context"
end

and this Capfile:

require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/rails"
require "capistrano/rbenv"
require "capistrano/bundler"
require "capistrano/scm/git"
require "capistrano/puma"

install_plugin Capistrano::Puma
install_plugin Capistrano::SCM::Git

set :rbenv_type, :user
set :rbenv_ruby, "2.7.1"

Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

I thought it was spring, then bootsnap, then my environment, but I have the exact same capistrano config on other projects and they work fine.

i think i will also post an issue to the capistrano3-puma repository


Solution

  • The solution was to lock the version of capistrano3-puma to 4.0.0:

    gem "capistrano3-puma", "4.0.0"
    

    because i was using puma 5 and the most recent version of capistrano3-puma was 1.2.1

    see this diff:

    -    capistrano3-puma (1.2.1)
    -      capistrano (~> 3.0)
    -      puma (>= 2.6)
    +    capistrano3-puma (4.0.0)
    +      capistrano (~> 3.7)
    +      capistrano-bundler
    +      puma (~> 4.0)