NameError: uninitialized constant Capistrano::Puma

NameError: uninitialized constant Capistrano::Puma

我得到了 NameError: uninitialized constant Capistrano::Puma 这个 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

和这个 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 }

我以为是 spring,然后是 bootsnap,然后是我的环境,但我在其他项目上有完全相同的 capistrano 配置,它们工作正常。

我想我也会 post capistrano3-puma 存储库的问题

解决方案是将 capistrano3-puma 的版本锁定为 4.0.0:

gem "capistrano3-puma", "4.0.0"

因为我使用的是 puma 5,而 capistrano3-puma 的最新版本是 1.2.1

查看此差异:

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

我遇到了同样的问题。这是因为我错误地安装了 capistrano-puma.

解决问题:

sudo gem uninstall capistrano-puma