有没有办法"gem install"只开发环境,或者测试?

Is there a way to "gem install" to only the development environment, or test?

如何使用 gem install,将 gem 添加到一个特定的环境,例如开发或测试或生产?如下图:

group :development do
  gem 'web-console', '>= 3.3.0'
end

您不能通过 gem 执行此操作,因为 Bundler 使用 Gemfile。但是,从 Bundler 版本 1.15.0 开始,您可以使用 bundle add:

bundle add web-console --group development

这会将以下行添加到您的 Gemfile:

gem "web-console", "~> 3.6", :group => [:development]