您正在尝试在更改 Gemfile 后以部署模式安装

You are trying to install in deployment mode after changing your Gemfile

我正在尝试使用

将我的 Rails 应用程序部署到我的 DigitalOcean 服务器
cap production deploy

但是我遇到了一个错误,

(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@178.62.204.53: bundle exit status: 16
bundle stdout: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

You have deleted from the Gemfile:
* rails-assets-angular-devise

You have changed in the Gemfile:
* rails-assets-angular-devise from `no specified source` to `rubygems repository
https://rubygems.org/, https://rails-assets.org/`
bundle stderr: Nothing written

SSHKit::Command::Failed: bundle exit status: 16
bundle stdout: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

You have deleted from the Gemfile:
* rails-assets-angular-devise

You have changed in the Gemfile:
* rails-assets-angular-devise from `no specified source` to `rubygems repository
https://rubygems.org/, https://rails-assets.org/`
bundle stderr: Nothing written

Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@178.62.204.53: bundle exit status: 16
bundle stdout: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

You have deleted from the Gemfile:
* rails-assets-angular-devise

You have changed in the Gemfile:
* rails-assets-angular-devise from `no specified source` to `rubygems repository
https://rubygems.org/, https://rails-assets.org/`
bundle stderr: Nothing written
alucardu@alucardu-VirtualBox:~/sites/movieseat(Deploy) $ source "https://rails-assets.org" do
bash: https://rails-assets.org: No such file or directory
alucardu@alucardu-VirtualBox:~/sites/movieseat(Deploy) $   gem "rails-assets-angular-devise"
ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command rails-assets-angular-devise
alucardu@alucardu-VirtualBox:~/sites/movieseat(Deploy) $ end

我的 Gemfile 和 Gemfile.lock 有问题,它与 rails-assets-angular-devise 有关,但我不知道如何修复它。

我在我的服务器上试过 运行 bundle install,但仍然出现同样的错误。我尝试删除 Gemlock.file 并在我的本地执行 bundle install 然后提交它并将其推送到我的部署分支但仍然是相同的错误。

这是 gemfile 中的 rails-assets-angular-devise 部分。

source "https://rails-assets.org" do
  gem "rails-assets-angular-devise"
end

正确检查服务器上的捆绑器版本 gemset - 可能你的 gemset 或本地 gem 中有旧的捆绑器版本(如果你不在服务器上使用 rvm )

我有同样的问题,解决步骤:

  • 登录服务器
  • 为您的应用正确切换 rvm
  • $ gem update bundler
  • 关闭 ssh 会话并重试 cap [env] deploy

出现此问题是因为您的部署服务器和开发服务器上的 bundler gem versions 不同。 bundler gem version 服务器和您的开发环境必须相等

在生产环境和开发环境中安装相同的捆绑程序版本后,使用以下命令再次部署:

cap production deploy

使用gem info bundler检查捆绑器版本并根据要求安装或卸载版本

安装:

gem install bundler -v <bundler_version>
E.g.
gem install bundler -v 2.2.4

卸载:

gem uninstall bundler -v <bundler_version>
E.g.
gem uninstall bundler -v 2.2.4