Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

'bundle outdated --group' not working as expected #6115

Closed
emilianoLeite opened this issue Oct 20, 2017 · 1 comment
Closed

'bundle outdated --group' not working as expected #6115

emilianoLeite opened this issue Oct 20, 2017 · 1 comment

Comments

@emilianoLeite
Copy link

emilianoLeite commented Oct 20, 2017

Hello, I'm encountering some strange behavior with the bundle outdated command, and first and foremost I would like to know if this really is a bug or an expected behavior.


Having an outdated rubocop gem in my Gemfile:

gem 'rubocop', groups: [:development, :test]

The command you ran

bundle outdated --group test

What you expected to happen

the gem rubocop is listed as outdated.

What actually happened

the gem rubocop was not listed as outdated.


So, here is my assumption:
When I write

gem 'rubocop', groups: [:development, :test]

or

group :development, :test do
  gem 'rubocop'
end

I expect that bundler will consider that the gem is in two separate groups, as if it were declared like this:

gem 'rubocop', :group => :development
gem 'rubocop', :group => :test

I searched the github docs and the bundler.io docs and it did not became clear to me if my assumption is correct.

Some more examples

  • Having an outdated rubocop gem in my Gemfile:
gem 'rubocop', groups: [:development, :test]
  • when I run:
    bundle outdated
  • the gem is correctly listed

  • Having an outdated rubocop gem in my Gemfile:
gem 'rubocop', groups: [:development, :test]
  • when I run:
    bundle outdated --group development
  • the gem is correctly listed

  • Having an outdated rubocop gem in my Gemfile:
gem 'rubocop', groups: [:development, :test]
  • when I run:
    bundle outdated --group test
  • the gem is not listed

I also created an automated test(https://github.com/emilianoLeite/bundler/commit/e6e8d4b034390150fe26dcd3ff9cfc4b0e34da55) to confirm this behavior.
The output of said automated test is as follows:

bundler|fix-outdated-group ⇒ rspec spec/commands/outdated_spec.rb:74
Could not find 'automatiek' (~> 0.1.0) among 31 total gem(s)
Checked in 'GEM_PATH=/Users/codus/.rvm/gems/ruby-2.3.3@bundle:/Users/codus/.rvm/gems/ruby-2.3.3@global', execute `gem env` for more information (Gem::MissingSpecError)
Could not find 'mustache' (= 0.99.6) among 31 total gem(s)
Checked in 'GEM_PATH=/Users/codus/.rvm/gems/ruby-2.3.3@bundle:/Users/codus/.rvm/gems/ruby-2.3.3@global', execute `gem env` for more information (Gem::MissingSpecError)
Could not find 'rdiscount' (~> 2.2) among 31 total gem(s)
Checked in 'GEM_PATH=/Users/codus/.rvm/gems/ruby-2.3.3@bundle:/Users/codus/.rvm/gems/ruby-2.3.3@global', execute `gem env` for more information (Gem::MissingSpecError)
Could not find 'ronn' (~> 0.7.3) among 31 total gem(s)
Checked in 'GEM_PATH=/Users/codus/.rvm/gems/ruby-2.3.3@bundle:/Users/codus/.rvm/gems/ruby-2.3.3@global', execute `gem env` for more information (Gem::MissingSpecError)
Install the ronn gem to build the help pages
man:build ran for   0.000000   0.000000   0.000000 (  0.000103)
Run options:
  include {:locations=>{"./spec/commands/outdated_spec.rb"=>[74]}}
  exclude {:bundler=>"=< 2.0", :rubygems_master=>true, :git=>"=< 2.11.0", :rubygems=>"=< 2.6.11", :ruby=>"=< 2.3.3", :realworld=>true, :sudo=>true}

bundle outdated
  with --group option
    not outdated gems
    returns a sorted list of outdated gems from one group => 'default'
    returns a sorted list of outdated gems from one group => 'development'
$ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby -rrubygems -S gem --backtrace generate_index
Generating Marshal quick index gemspecs for 61 gems
.............................................................
Complete
Generated Marshal quick index gemspecs: 0.061s
Generating specs index
Generated specs index: 0.003s
Generating latest specs index
Generated latest specs index: 0.001s
Generating prerelease specs index
Generated prerelease specs index: 0.002s
Compressing indices
Compressed indices: 0.002s
# $? => 0

$ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
  -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
  -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
  /Users/codus/Projects/bundler/exe/bundle install --retry 0 --no-color
Fetching /Users/codus/Projects/bundler/tmp/libs/zebra
Fetching /Users/codus/Projects/bundler/tmp/libs/foo
Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
Resolving dependencies...
Fetching activesupport 2.3.5
Fetching duradura 7.0
Fetching terranova 8
Fetching weakling 0.0.3
Installing weakling 0.0.3
Installing terranova 8
Installing activesupport 2.3.5
Installing duradura 7.0
Bundle complete! 6 Gemfile dependencies, 7 gems now installed.
Bundled gems are installed into `./.bundle`
# $? => 0

$ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
  -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
  -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
  /Users/codus/Projects/bundler/exe/bundle install --retry 0 --no-color
Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
Resolving dependencies...
Bundle complete! 4 Gemfile dependencies, 5 gems now installed.
Bundled gems are installed into `./.bundle`
Removing foo (a427292f2204)
Removing zebra (b875e4b9f775)
# $? => 0

$ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby -rrubygems -S gem --backtrace generate_index
Generating Marshal quick index gemspecs for 64 gems
................................................................
Complete
Generated Marshal quick index gemspecs: 0.106s
Generating specs index
Generated specs index: 0.004s
Generating latest specs index
Generated latest specs index: 0.002s
Generating prerelease specs index
Generated prerelease specs index: 0.000s
Compressing indices
Compressed indices: 0.002s
# $? => 0

$ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
  -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
  -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
  /Users/codus/Projects/bundler/exe/bundle outdated --group test --no-color
Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
Resolving dependencies...

Outdated gems included in the bundle:
# $? => 1
    returns a sorted list of outdated gems from one group => 'test' (FAILED - 1)


Retried examples: 0

Failures:

  1) bundle outdated with --group option returns a sorted list of outdated gems from one group => 'test'
     Failure/Error: expect(gem_list.size).to eq gems_list_size
     
       expected: 2
            got: 0
     
       (compared using ==)
     
     
       Commands:
       $ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby -rrubygems -S gem --backtrace generate_index
       Generating Marshal quick index gemspecs for 61 gems
       .............................................................
       Complete
       Generated Marshal quick index gemspecs: 0.061s
       Generating specs index
       Generated specs index: 0.003s
       Generating latest specs index
       Generated latest specs index: 0.001s
       Generating prerelease specs index
       Generated prerelease specs index: 0.002s
       Compressing indices
       Compressed indices: 0.002s
       # $? => 0
     
       $ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
         -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
         -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
         /Users/codus/Projects/bundler/exe/bundle install --retry 0 --no-color
       Fetching /Users/codus/Projects/bundler/tmp/libs/zebra
       Fetching /Users/codus/Projects/bundler/tmp/libs/foo
       Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
       Resolving dependencies...
       Fetching activesupport 2.3.5
       Fetching duradura 7.0
       Fetching terranova 8
       Fetching weakling 0.0.3
       Installing weakling 0.0.3
       Installing terranova 8
       Installing activesupport 2.3.5
       Installing duradura 7.0
       Bundle complete! 6 Gemfile dependencies, 7 gems now installed.
       Bundled gems are installed into `./.bundle`
       # $? => 0
     
       $ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
         -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
         -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
         /Users/codus/Projects/bundler/exe/bundle install --retry 0 --no-color
       Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
       Resolving dependencies...
       Bundle complete! 4 Gemfile dependencies, 5 gems now installed.
       Bundled gems are installed into `./.bundle`
       Removing foo (a427292f2204)
       Removing zebra (b875e4b9f775)
       # $? => 0
     
       $ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby -rrubygems -S gem --backtrace generate_index
       Generating Marshal quick index gemspecs for 64 gems
       ................................................................
       Complete
       Generated Marshal quick index gemspecs: 0.106s
       Generating specs index
       Generated specs index: 0.004s
       Generating latest specs index
       Generated latest specs index: 0.002s
       Generating prerelease specs index
       Generated prerelease specs index: 0.000s
       Compressing indices
       Compressed indices: 0.002s
       # $? => 0
     
       $ /Users/codus/.rvm/rubies/ruby-2.3.3/bin/ruby \
         -I/Users/codus/Projects/bundler/lib:/Users/codus/Projects/bundler/spec -rsupport/hax \
         -r/Users/codus/Projects/bundler/spec/support/artifice/fail \
         /Users/codus/Projects/bundler/exe/bundle outdated --group test --no-color
       Fetching source index from file:/Users/codus/Projects/bundler/tmp/gems/remote2/
       Resolving dependencies...
     
       Outdated gems included in the bundle:
       # $? => 1
     # ./spec/commands/outdated_spec.rb:98:in `test_group_option'
     # ./spec/commands/outdated_spec.rb:140:in `block (3 levels) in <top (required)>'

Finished in 18.62 seconds (files took 0.70388 seconds to load)
4 examples, 1 failure

Failed examples:

rspec ./spec/commands/outdated_spec.rb:139 # bundle outdated with --group option returns a sorted list of outdated gems from one group => 'test'

So, again: is this a bug or an expected behavior?

If it is a bug, I would be happy to try to fix it 😄 .

Cheers.

@segiddins
Copy link
Member

#6116 should fix this!

bundlerbot added a commit that referenced this issue Oct 25, 2017
…dale

[Outdated] Support --group with the second group for a dependency

### What was the end-user problem that led to this PR?

The problem was `bundle outdated --group NAME` wouldn't work if it was the second group for the dependency.

Closes #6115.

### What was your diagnosis of the problem?

My diagnosis was we were joining with `, ` and splitting on `,`, so subsequent groups had an additional space.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants