Ruby-on-rails Rails bundler 不会在组内安装 gems

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4118055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:35:28  来源:igfitidea点击:

Rails bundler doesn't install gems inside a group

ruby-on-railsrubyrubygemsbundler

提问by picardo

I have several gems including ruby-debug in a bundler group called :development. When I run the bundle command, these gems are ignored and it only installs the gems that are not in any group. How can I make sure bundler doesn't ignore the gems in the :development group?

我在一个名为 :development 的打包程序组中有几个 gem,包括 ruby​​-debug。当我运行 bundle 命令时,这些 gems 被忽略,它只安装不在任何组中的 gems。如何确保 bundler 不会忽略 :development 组中的 gem?

Edit: This is what my Gemfile looks like.

编辑:这就是我的 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

回答by oma

Within a term session, it remembers the withoutoption. If you first ran

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

bundle install --without development 

it remembers that you did this and will automatically repeat this for the next

它会记住你做了这个,并会自动在下一个重复这个

bundle install #remembers and includes --without development

running something else, like bundle install --without nothingshould clear the cache. Am I right?

运行其他东西,比如bundle install --without nothing应该清除缓存。我对吗?

update 20150214:This is fixed in bundler 2.0, according to issue referenced in comment by @Stan Bondi (https://github.com/bundler/bundler/issues/2862). Thanks Stan.

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

回答by mahatmanich

If you are using rails, there will be a file configwritten to a hidden dir called .bundlein your rails root directory:

如果您使用的是 rails,将会有一个文件config写入.bundle您的 rails 根目录中的隐藏目录:

.bundle/config

This file, in my case, held exactly the withoutsettings.

在我的情况下,这个文件完全保存了without设置。

So I just deleted the .bundledirectory:

所以我只是删除了.bundle目录:

rm .bundle -r

After that:

在那之后:

bundle installworked again as expected.

bundle install再次按预期工作。

Using: bundler (1.5.2)

回答by Vladislav Leonov

I had the same issue and --withflag worked for me. You need to pass group name, which you want to include. Like that:

我遇到了同样的问题,--withflag 对我有用。您需要传递要包含的组名。像那样:

bundle install --with development

回答by vijaya

    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)

More

更多的

回答by Marek P?íhoda

I had a similar problem - thin in staging ignored - and the solution was to put it out if staging into the 'global' space:

我有一个类似的问题 - 忽略分期薄 - 解决方案是在分期到“全局”空间时将其删除:

gem 'thin'

group :production do
  gem 'puma'
end

回答by pex

In fact Rails loads the :developmentgroup automatically when in development environment. Check whether Rails.envin you App really returns "development".

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

More Information about groups in Bundler: http://gembundler.com/groups.html

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