红宝石-Rails bundler不会在组内安装宝石

我在一个叫做:development的捆绑程序组中有很多宝石,包括ruby-debug。 当我运行bundle命令时,这些gems会被忽略,并且只会安装不在任何组中的gems。 如何确保捆绑程序不忽略:development组中的gems?

编辑:这就是我的Gemfile的样子。

source 'http://rubygems.org'
gem 'rails', '3.0.1'

# Auth gems
gem "devise", "1.1.3"
gem "omniauth"

# Bundle Mongoid gems
gem "mongoid", "2.0.0.beta.19"
gem "bson_ext"

# Asset gems
gem 'jquery-rails'
gem "jammit"

# Controller gems
gem 'inherited_resources', '1.1.2'

# View gems
gem 'haml'
gem 'formtastic', '~> 1.1.0'

# Nokogiri
gem "mechanize"
gem "json"


group :development do
  gem "ruby-debug"
  gem 'compass'
  gem 'compass-colors'
  gem 'pickler'
  gem 'haml-rails'
  gem 'rails3-generators'
  gem "hpricot"
  gem "ruby_parser"
  gem 'fog'
end
picardo asked 2019-11-14T20:14:10Z
6个解决方案
130 votes

在学期中,它会记住without选项。 如果你第一次跑

bundle install --without development 

它会记住您已执行此操作,并会在下一次自动重复此操作

bundle install #remembers and includes --without development

运行其他内容,例如bundle install --without nothing,应清除缓存。 我对吗?

更新20150214:根据@Stan Bondi([https://github.com/bundler/bundler/issues/2862)在评论中引用的问题,此问题在捆绑程序2.0中已修复。]谢谢Stan。

oma answered 2019-11-14T20:14:49Z
29 votes

如果您使用的是rails,则在rails根目录中将有一个文件bundle install写入名为.bundle的隐藏目录中:

.bundle/config

以我为例,该文件完全保留了261430640781820002000的设置。

所以我刚刚删除了261430640781820002000目录:

rm .bundle -r

之后:

bundle install再次按预期工作。

Using: bundler (1.5.2)
mahatmanich answered 2019-11-14T20:15:38Z
11 votes

我遇到了同样的问题,并且--with标志为我工作。 您需要传递要包含的组名。 像那样:

bundle install --with development
Vladislav Leonov answered 2019-11-14T20:16:03Z
2 votes
    gem 'aws-s3'
    gem 'paperclip'
      group :test do
        gem 'rspec'
        gem 'waitr'
        gem 'faker'
      end

gem 'rest-client', :group => :development
gem 'cucuber-rails', :groups => [:development,:test]  (cucuber-rails gems comes under both group)

bundle install --without development #(ignore development group gems)
bundle install #(still bundle remembers --without development so result is still ignore development groups it will not install all gems)

bundle install --without nothing #(just clearing cache, now all the gems to be loaded into the ruby loadpath)

更多

vijaya answered 2019-11-14T20:16:22Z
0 votes

实际上,Rails在开发环境中时会自动加载:development组。 检查您的应用中的Rails.env是否真的返回"development"

有关Bundler中群组的更多信息:[http://gembundler.com/groups.html]

pex answered 2019-11-14T20:16:54Z
0 votes

我有一个类似的问题-分阶段忽略不清-解决方案是在分阶段进入“全局”空间时将其淘汰:

gem 'thin'

group :production do
  gem 'puma'
end
maprihoda answered 2019-11-14T20:17:19Z
translate from https://stackoverflow.com:/questions/4118055/rails-bundler-doesnt-install-gems-inside-a-group