bundler 1.16.6 → 1.17.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -18
  3. data/README.md +1 -1
  4. data/bundler.gemspec +1 -1
  5. data/lib/bundler.rb +2 -2
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli.rb +32 -18
  8. data/lib/bundler/cli/add.rb +15 -5
  9. data/lib/bundler/cli/doctor.rb +47 -1
  10. data/lib/bundler/cli/install.rb +8 -5
  11. data/lib/bundler/cli/list.rb +41 -5
  12. data/lib/bundler/cli/outdated.rb +7 -1
  13. data/lib/bundler/cli/pristine.rb +4 -0
  14. data/lib/bundler/definition.rb +28 -34
  15. data/lib/bundler/endpoint_specification.rb +1 -1
  16. data/lib/bundler/env.rb +6 -8
  17. data/lib/bundler/feature_flag.rb +5 -0
  18. data/lib/bundler/fetcher.rb +1 -1
  19. data/lib/bundler/gem_helper.rb +1 -1
  20. data/lib/bundler/gem_version_promoter.rb +4 -2
  21. data/lib/bundler/injector.rb +14 -3
  22. data/lib/bundler/installer.rb +29 -6
  23. data/lib/bundler/installer/gem_installer.rb +1 -1
  24. data/lib/bundler/installer/parallel_installer.rb +6 -1
  25. data/lib/bundler/mirror.rb +2 -2
  26. data/lib/bundler/plugin.rb +9 -2
  27. data/lib/bundler/plugin/events.rb +61 -0
  28. data/lib/bundler/plugin/index.rb +1 -1
  29. data/lib/bundler/resolver.rb +2 -2
  30. data/lib/bundler/resolver/spec_group.rb +4 -0
  31. data/lib/bundler/runtime.rb +9 -3
  32. data/lib/bundler/settings.rb +23 -2
  33. data/lib/bundler/settings/validator.rb +23 -0
  34. data/lib/bundler/source.rb +9 -9
  35. data/lib/bundler/source/metadata.rb +1 -1
  36. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
  37. data/lib/bundler/templates/newgem/newgem.gemspec.tt +0 -4
  38. data/lib/bundler/version.rb +1 -1
  39. data/man/bundle-add.1 +18 -3
  40. data/man/bundle-add.1.txt +17 -5
  41. data/man/bundle-add.ronn +13 -2
  42. data/man/bundle-binstubs.1 +1 -1
  43. data/man/bundle-binstubs.1.txt +1 -1
  44. data/man/bundle-check.1 +1 -1
  45. data/man/bundle-check.1.txt +1 -1
  46. data/man/bundle-clean.1 +1 -1
  47. data/man/bundle-clean.1.txt +1 -1
  48. data/man/bundle-config.1 +10 -1
  49. data/man/bundle-config.1.txt +22 -10
  50. data/man/bundle-config.ronn +7 -0
  51. data/man/bundle-doctor.1 +1 -1
  52. data/man/bundle-doctor.1.txt +1 -1
  53. data/man/bundle-exec.1 +1 -1
  54. data/man/bundle-exec.1.txt +1 -1
  55. data/man/bundle-gem.1 +1 -1
  56. data/man/bundle-gem.1.txt +1 -1
  57. data/man/bundle-info.1 +1 -1
  58. data/man/bundle-info.1.txt +1 -1
  59. data/man/bundle-init.1 +1 -1
  60. data/man/bundle-init.1.txt +1 -1
  61. data/man/bundle-inject.1 +1 -1
  62. data/man/bundle-inject.1.txt +1 -1
  63. data/man/bundle-install.1 +2 -5
  64. data/man/bundle-install.1.txt +7 -17
  65. data/man/bundle-install.ronn +2 -11
  66. data/man/bundle-list.1 +32 -2
  67. data/man/bundle-list.1.txt +24 -2
  68. data/man/bundle-list.ronn +19 -1
  69. data/man/bundle-lock.1 +1 -1
  70. data/man/bundle-lock.1.txt +1 -1
  71. data/man/bundle-open.1 +1 -1
  72. data/man/bundle-open.1.txt +1 -1
  73. data/man/bundle-outdated.1 +6 -2
  74. data/man/bundle-outdated.1.txt +10 -6
  75. data/man/bundle-outdated.ronn +4 -0
  76. data/man/bundle-package.1 +1 -1
  77. data/man/bundle-package.1.txt +1 -1
  78. data/man/bundle-platform.1 +1 -1
  79. data/man/bundle-platform.1.txt +1 -1
  80. data/man/bundle-pristine.1 +1 -1
  81. data/man/bundle-pristine.1.txt +1 -1
  82. data/man/bundle-show.1 +1 -1
  83. data/man/bundle-show.1.txt +1 -1
  84. data/man/bundle-update.1 +6 -10
  85. data/man/bundle-update.1.txt +14 -16
  86. data/man/bundle-update.ronn +6 -10
  87. data/man/bundle-viz.1 +1 -1
  88. data/man/bundle-viz.1.txt +1 -1
  89. data/man/bundle.1 +1 -1
  90. data/man/bundle.1.txt +1 -1
  91. data/man/gemfile.5 +1 -1
  92. data/man/gemfile.5.txt +1 -1
  93. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c8701ee4e255c1f26c310125b8d2024291f1bb63e14f5888595777c9cb3bce3
4
- data.tar.gz: a05cfecd3e025afcfe093d0b3e84696187f3248fb19d048ce08aae9bb15bc7c9
3
+ metadata.gz: 8836a89065342b7a101685c55a3bcc17381204df615f228f8440760e355b3bfb
4
+ data.tar.gz: bde77176dcf8f419b2b73053659956a694c24e0aebef29267dbd254d29bed1ec
5
5
  SHA512:
6
- metadata.gz: 28a609892a9961e26de6bf9dcd83dbcb8feb9be34a26b8a231a13ef18a461b10c6c8b1128ef2b343c2e23b8e474333a55fb8be9303215d3127a898aeba43bcf4
7
- data.tar.gz: ee74ea9ba33bf9c7acdb0065484b3cd09ef6760e88aa2b3498e0f7d5217e43b8b42fcf755ef02ffc1ab1155f9b3334e1d66b0bc61c906e48f8a4c497521c2bd1
6
+ metadata.gz: 96b057a613a2831a1a2f27ba8392e17f6b35d213854bd43219897bbc8bfe3db57c54a4e808e45ac2ff636dd615c170ce7764008ec376a5af9070b76e86de680e
7
+ data.tar.gz: 688ac2c143586a844b095ce9493b239de94ea6f993d7963ad63c2097e42e714da60bc118a9984b4a6712e6249db85bfa1bd8d24931eac2a37ee4373d30f538bc
@@ -1,24 +1,28 @@
1
- ## 1.16.6 (2018-10-05)
1
+ ## 1.17.0.pre.1 (2018-09-24)
2
2
 
3
- Changes:
4
-
5
- - Add an error message when adding a gem with `bundle add` that's already in the bundle ([#6341](https://github.com/bundler/bundler/issues/6341), @agrim123)
6
- - Add Homepage, Source Code and Chanagelog URI metadata fields to the `bundle gem` gemspec template (@walf443)
7
-
8
- Bugfixes:
3
+ Features:
9
4
 
10
- - Fix issue where updating a gem resulted in the gem's version being downgraded when `BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS` was set ([#6529](https://github.com/bundler/bundler/issues/6529), @theflow)
11
- - Fix some rescue calls that don't specifiy error type (@utilum)
12
- - Fix an issue when the Lockfile would contain platform-specific gems that it didn't need ([#6491](https://github.com/bundler/bundler/issues/6491), @segiddins)
13
- - Improve handlding of adding new gems with only a single group to the Gemfile in `bundle add` (@agrim123)
14
- - Refactor check for OpenSSL in `bundle env` (@voxik)
15
- - Remove an unnecessary assignment in Metadata (@voxik)
5
+ - Check folder/file permissions of the Bundle home directory in the `bundle doctor` command ([#5786](https://github.com/bundler/bundler/issues/5786), @ajwann)
6
+ - Remove compiled gem extensions when running `bundle clean` ([#5596](https://github.com/bundler/bundler/issues/5596), @akhramov)
7
+ - Add `--paths` option to `bundle list` command ([#6172](https://github.com/bundler/bundler/issues/6172), @colby-swandale)
8
+ - Add base error class to gems generated from `bundle gem` ([#6260](https://github.com/bundler/bundler/issues/6260), @christhekeele)
9
+ - Correctly re-install gem extensions with a git source when running `bundle pristine` ([#6294](https://github.com/bundler/bundler/issues/6294), @wagenet)
10
+ - Add config option to disable platform warnings ([#6124](https://github.com/bundler/bundler/issues/6124), @agrim123)
11
+ - Add `--skip-install` option to `bundle add` command to add gems to the Gemfile without installation ([#6511](https://github.com/bundler/bundler/issues/6511), @agrim123)
12
+ - Add `--only-explicit` option to `bundle outdated` to list only outdated gems in the Gemfile ([#5366](https://github.com/bundler/bundler/issues/5366), @peret)
13
+ - Support adding multiple gems to the Gemfile with `bundle add` ([#6543](https://github.com/bundler/bundler/issues/6543), @agrim123)
14
+ - Make registered plugin events easier to manage in the Plugin API (@jules2689)
15
+ - Add new gem install hooks to the Plugin API (@jules2689)
16
+ - Add `--optimistic` and `--strict` options to `bundle add` ([#6553](https://github.com/bundler/bundler/issues/6553), @agrim123)
17
+ - Add `--without-group` and `--only-group` options to `bundle list` ([#6564](https://github.com/bundler/bundler/issues/6564), @agrim123)
18
+ - Add `--gemfile` option to the `bundle exec` command ([#5924](https://github.com/bundler/bundler/issues/5924), @ankitkataria)
16
19
 
17
- Documentation:
20
+ The following new features are available but are not enabled by default. These are intended to be tested by users for the upcoming release of Bundler 2.
18
21
 
19
- - Update docs to reflect revised guidance to check in Gemfile.lock into version control for gems ([#5879](https://github.com/bundler/bundler/issues/5879), @arbonap)
20
- - Add documentation for the `--all` flag in `bundle update` (@agrim123)
21
- - Update README to use `bundle add` in usage examples (@hdf1986)
22
+ - Make `install --path` relative to the current working directory ([#2048](https://github.com/bundler/bundler/issues/2048), @igorbozato)
23
+ - Auto-configure job count ([#5808](https://github.com/bundler/bundler/issues/5808), @segiddins)
24
+ - Use the Gem Version Promoter for major gem updates ([#5993](https://github.com/bundler/bundler/issues/5993), @segiddins)
25
+ - Add config option to add the Ruby scope to `bundle config path` when configured globally (@segiddins)
22
26
 
23
27
  ## 1.16.5 (2018-09-18)
24
28
 
@@ -36,7 +40,7 @@ Bugfixes:
36
40
  - Check that Bundler::Deprecate is not an autoload constant ([#6163](https://github.com/bundler/bundler/issues/6163), @eregon)
37
41
  - Prefer non-pre-release versions when performing a `bundle update --patch` ([#6684](https://github.com/bundler/bundler/issues/6684), @segiddins)
38
42
 
39
- ## 1.16.4 (2018-08-17)
43
+ ## 1.16.4 (2017-08-17)
40
44
 
41
45
  Changes:
42
46
 
data/README.md CHANGED
@@ -24,7 +24,7 @@ Bundler is most commonly used to manage your application's dependencies. For exa
24
24
 
25
25
  ```
26
26
  bundle init
27
- bundle add rspec
27
+ echo 'gem "rspec"' >> Gemfile
28
28
  bundle install
29
29
  bundle exec rspec
30
30
  ```
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.license = "MIT"
11
11
  s.authors = [
12
12
  "André Arko", "Samuel Giddins", "Colby Swandale", "Hiroshi Shibata",
13
- "David Rodríguez", "Grey Baker", "Stephanie Morillo", "Chris Morris", "James Wen", "Tim Moore",
13
+ "David Rodríguez", "Grey Baker", "Chris Morris", "James Wen", "Tim Moore",
14
14
  "André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
15
15
  "Yehuda Katz"
16
16
  ]
@@ -191,7 +191,7 @@ module Bundler
191
191
  end
192
192
  tmp_home_path.join(login).tap(&:mkpath)
193
193
  end
194
- rescue RuntimeError => e
194
+ rescue => e
195
195
  raise e.exception("#{warning}\nBundler also failed to create a temporary home directory at `#{path}':\n#{e}")
196
196
  end
197
197
 
@@ -416,7 +416,7 @@ EOF
416
416
 
417
417
  def load_marshal(data)
418
418
  Marshal.load(data)
419
- rescue StandardError => e
419
+ rescue => e
420
420
  raise MarshalError, "#{e.class}: #{e.message}"
421
421
  end
422
422
 
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2018-10-05".freeze
8
- @git_commit_sha = "f66c33467".freeze
7
+ @built_at = "2018-09-23".freeze
8
+ @git_commit_sha = "9263a0a3a".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -233,6 +233,8 @@ module Bundler
233
233
  D
234
234
  method_option "full-index", :type => :boolean, :banner =>
235
235
  "Fall back to using the single-file index of all gems"
236
+ method_option "gemfile", :type => :string, :banner =>
237
+ "Use the specified gemfile instead of Gemfile"
236
238
  method_option "group", :aliases => "-g", :type => :array, :banner =>
237
239
  "Update a specific group"
238
240
  method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
@@ -285,6 +287,9 @@ module Bundler
285
287
  if Bundler.feature_flag.list_command?
286
288
  desc "list", "List all gems in the bundle"
287
289
  method_option "name-only", :type => :boolean, :banner => "print only the gem names"
290
+ method_option "only-group", :type => :string, :banner => "print gems from a particular group"
291
+ method_option "without-group", :type => :string, :banner => "print all gems expect from a group"
292
+ method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
288
293
  def list
289
294
  require "bundler/cli/list"
290
295
  List.new(options).run
@@ -328,10 +333,13 @@ module Bundler
328
333
  method_option "version", :aliases => "-v", :type => :string
329
334
  method_option "group", :aliases => "-g", :type => :string
330
335
  method_option "source", :aliases => "-s", :type => :string
331
-
332
- def add(gem_name)
336
+ method_option "skip-install", :type => :boolean, :banner =>
337
+ "Adds gem to the Gemfile but does not install it"
338
+ method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
339
+ method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
340
+ def add(*gems)
333
341
  require "bundler/cli/add"
334
- Add.new(options.dup, gem_name).run
342
+ Add.new(options.dup, gems).run
335
343
  end
336
344
 
337
345
  desc "outdated GEM [OPTIONS]", "List installed gems with newer versions available"
@@ -362,6 +370,8 @@ module Bundler
362
370
  method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
363
371
  method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
364
372
  "Use minimal formatting for more parseable output"
373
+ method_option "only-explicit", :type => :boolean, :banner =>
374
+ "Only list gems specified in your Gemfile, not their dependencies"
365
375
  def outdated(*gems)
366
376
  require "bundler/cli/outdated"
367
377
  Outdated.new(options, gems).run
@@ -413,6 +423,7 @@ module Bundler
413
423
 
414
424
  desc "exec [OPTIONS]", "Run the command in context of the bundle"
415
425
  method_option :keep_file_descriptors, :type => :boolean, :default => false
426
+ method_option :gemfile, :type => :string, :required => false
416
427
  long_desc <<-D
417
428
  Exec runs a command, providing it access to the gems in the bundle. While using
418
429
  bundle exec you can require and call the bundled gems as if they were installed
@@ -485,20 +496,23 @@ module Bundler
485
496
  end
486
497
  end
487
498
 
488
- desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
489
- long_desc <<-D
490
- Viz generates a PNG file of the current Gemfile as a dependency graph.
491
- Viz requires the ruby-graphviz gem (and its dependencies).
492
- The associated gems must also be installed via 'bundle install'.
493
- D
494
- method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
495
- method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
496
- method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
497
- method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
498
- method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
499
- def viz
500
- require "bundler/cli/viz"
501
- Viz.new(options.dup).run
499
+ if Bundler.feature_flag.viz_command?
500
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
501
+ long_desc <<-D
502
+ Viz generates a PNG file of the current Gemfile as a dependency graph.
503
+ Viz requires the ruby-graphviz gem (and its dependencies).
504
+ The associated gems must also be installed via 'bundle install'.
505
+ D
506
+ method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
507
+ method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
508
+ method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
509
+ method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
510
+ method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
511
+ def viz
512
+ SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
513
+ require "bundler/cli/viz"
514
+ Viz.new(options.dup).run
515
+ end
502
516
  end
503
517
 
504
518
  old_gem = instance_method(:gem)
@@ -741,7 +755,7 @@ module Bundler
741
755
  end
742
756
 
743
757
  Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
744
- rescue RuntimeError
758
+ rescue
745
759
  nil
746
760
  end
747
761
  end
@@ -2,13 +2,18 @@
2
2
 
3
3
  module Bundler
4
4
  class CLI::Add
5
- def initialize(options, gem_name)
6
- @gem_name = gem_name
5
+ def initialize(options, gems)
6
+ @gems = gems
7
7
  @options = options
8
8
  @options[:group] = @options[:group].split(",").map(&:strip) if !@options[:group].nil? && !@options[:group].empty?
9
9
  end
10
10
 
11
11
  def run
12
+ raise InvalidOption, "You can not specify `--strict` and `--optimistic` at the same time." if @options[:strict] && @options[:optimistic]
13
+
14
+ # raise error when no gems are specified
15
+ raise InvalidOption, "Please specify gems to add." if @gems.empty?
16
+
12
17
  version = @options[:version].nil? ? nil : @options[:version].split(",").map(&:strip)
13
18
 
14
19
  unless version.nil?
@@ -16,10 +21,15 @@ module Bundler
16
21
  raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s
17
22
  end
18
23
  end
19
- dependency = Bundler::Dependency.new(@gem_name, version, @options)
20
24
 
21
- Injector.inject([dependency], :conservative_versioning => @options[:version].nil?) # Perform conservative versioning only when version is not specified
22
- Installer.install(Bundler.root, Bundler.definition)
25
+ dependencies = @gems.map {|g| Bundler::Dependency.new(g, version, @options) }
26
+
27
+ Injector.inject(dependencies,
28
+ :conservative_versioning => @options[:version].nil?, # Perform conservative versioning only when version is not specified
29
+ :optimistic => @options[:optimistic],
30
+ :strict => @options[:strict])
31
+
32
+ Installer.install(Bundler.root, Bundler.definition) unless @options["skip-install"]
23
33
  end
24
34
  end
25
35
  end
@@ -78,6 +78,8 @@ module Bundler
78
78
  end
79
79
  end
80
80
 
81
+ permissions_valid = check_home_permissions
82
+
81
83
  if broken_links.any?
82
84
  message = "The following gems are missing OS dependencies:"
83
85
  broken_links.map do |spec, paths|
@@ -86,9 +88,53 @@ module Bundler
86
88
  end
87
89
  end.flatten.sort.each {|m| message += m }
88
90
  raise ProductionError, message
89
- else
91
+ elsif !permissions_valid
90
92
  Bundler.ui.info "No issues found with the installed bundle"
91
93
  end
92
94
  end
95
+
96
+ private
97
+
98
+ def check_home_permissions
99
+ require "find"
100
+ files_not_readable_or_writable = []
101
+ files_not_rw_and_owned_by_different_user = []
102
+ files_not_owned_by_current_user_but_still_rw = []
103
+ Find.find(Bundler.home.to_s).each do |f|
104
+ if !File.writable?(f) || !File.readable?(f)
105
+ if File.stat(f).uid != Process.uid
106
+ files_not_rw_and_owned_by_different_user << f
107
+ else
108
+ files_not_readable_or_writable << f
109
+ end
110
+ elsif File.stat(f).uid != Process.uid
111
+ files_not_owned_by_current_user_but_still_rw << f
112
+ end
113
+ end
114
+
115
+ ok = true
116
+ if files_not_owned_by_current_user_but_still_rw.any?
117
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
118
+ "user, but are still readable/writable. These files are:\n - #{files_not_owned_by_current_user_but_still_rw.join("\n - ")}"
119
+
120
+ ok = false
121
+ end
122
+
123
+ if files_not_rw_and_owned_by_different_user.any?
124
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
125
+ "user, and are not readable/writable. These files are:\n - #{files_not_rw_and_owned_by_different_user.join("\n - ")}"
126
+
127
+ ok = false
128
+ end
129
+
130
+ if files_not_readable_or_writable.any?
131
+ Bundler.ui.warn "Files exist in the Bundler home that are not " \
132
+ "readable/writable by the current user. These files are:\n - #{files_not_readable_or_writable.join("\n - ")}"
133
+
134
+ ok = false
135
+ end
136
+
137
+ ok
138
+ end
93
139
  end
94
140
  end
@@ -71,8 +71,7 @@ module Bundler
71
71
  if Bundler.use_system_gems?
72
72
  Bundler.ui.confirm "Use `bundle info [gemname]` to see where a bundled gem is installed."
73
73
  else
74
- absolute_path = File.expand_path(Bundler.configured_bundle_path.base_path)
75
- relative_path = absolute_path.sub(File.expand_path(".") + File::SEPARATOR, "." + File::SEPARATOR)
74
+ relative_path = Bundler.configured_bundle_path.base_path_relative_to_pwd
76
75
  Bundler.ui.confirm "Bundled gems are installed into `#{relative_path}`"
77
76
  end
78
77
 
@@ -169,9 +168,13 @@ module Bundler
169
168
 
170
169
  def normalize_settings
171
170
  Bundler.settings.set_command_option :path, nil if options[:system]
172
- Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment]
173
- Bundler.settings.set_command_option_if_given :path, options["path"]
174
- Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
171
+ Bundler.settings.temporary(:path_relative_to_cwd => false) do
172
+ Bundler.settings.set_command_option :path, "vendor/bundle" if options[:deployment]
173
+ end
174
+ Bundler.settings.set_command_option_if_given :path, options[:path]
175
+ Bundler.settings.temporary(:path_relative_to_cwd => false) do
176
+ Bundler.settings.set_command_option :path, "bundle" if options["standalone"] && Bundler.settings[:path].nil?
177
+ end
175
178
 
176
179
  bin_option = options["binstubs"]
177
180
  bin_option = nil if bin_option && bin_option.empty?
@@ -7,16 +7,52 @@ module Bundler
7
7
  end
8
8
 
9
9
  def run
10
- specs = Bundler.load.specs.reject {|s| s.name == "bundler" }.sort_by(&:name)
11
- return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
10
+ raise InvalidOption, "The `--only-group` and `--without-group` options cannot be used together" if @options["only-group"] && @options["without-group"]
11
+
12
+ raise InvalidOption, "The `--name-only` and `--paths` options cannot be used together" if @options["name-only"] && @options[:paths]
13
+
14
+ specs = if @options["only-group"] || @options["without-group"]
15
+ filtered_specs_by_groups
16
+ else
17
+ Bundler.load.specs
18
+ end.reject {|s| s.name == "bundler" }.sort_by(&:name)
12
19
 
13
20
  return Bundler.ui.info "No gems in the Gemfile" if specs.empty?
21
+
22
+ return specs.each {|s| Bundler.ui.info s.name } if @options["name-only"]
23
+ return specs.each {|s| Bundler.ui.info s.full_gem_path } if @options["paths"]
24
+
14
25
  Bundler.ui.info "Gems included by the bundle:"
15
- specs.each do |s|
16
- Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
17
- end
26
+
27
+ specs.each {|s| Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" }
18
28
 
19
29
  Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
20
30
  end
31
+
32
+ private
33
+
34
+ def verify_group_exists(groups)
35
+ raise InvalidOption, "`#{@options["without-group"]}` group could not be found." if @options["without-group"] && !groups.include?(@options["without-group"].to_sym)
36
+
37
+ raise InvalidOption, "`#{@options["only-group"]}` group could not be found." if @options["only-group"] && !groups.include?(@options["only-group"].to_sym)
38
+ end
39
+
40
+ def filtered_specs_by_groups
41
+ definition = Bundler.definition
42
+ groups = definition.groups
43
+
44
+ verify_group_exists(groups)
45
+
46
+ show_groups =
47
+ if @options["without-group"]
48
+ groups.reject {|g| g == @options["without-group"].to_sym }
49
+ elsif @options["only-group"]
50
+ groups.select {|g| g == @options["only-group"].to_sym }
51
+ else
52
+ groups
53
+ end.map(&:to_sym)
54
+
55
+ definition.specs_for(show_groups)
56
+ end
21
57
  end
22
58
  end
@@ -66,7 +66,13 @@ module Bundler
66
66
  current_dependencies.key? spec.name
67
67
  end
68
68
 
69
- (gemfile_specs + dependency_specs).sort_by(&:name).each do |current_spec|
69
+ specs = if options["only-explicit"]
70
+ gemfile_specs
71
+ else
72
+ gemfile_specs + dependency_specs
73
+ end
74
+
75
+ specs.sort_by(&:name).each do |current_spec|
70
76
  next if !gems.empty? && !gems.include?(current_spec.name)
71
77
 
72
78
  dependency = current_dependencies[current_spec.name]
@@ -30,6 +30,10 @@ module Bundler
30
30
  FileUtils.rm_rf spec.full_gem_path
31
31
  when Source::Git
32
32
  source.remote!
33
+ if extension_cache_path = source.extension_cache_path(spec)
34
+ FileUtils.rm_rf extension_cache_path
35
+ end
36
+ FileUtils.rm_rf spec.extension_dir if spec.respond_to?(:extension_dir)
33
37
  FileUtils.rm_rf spec.full_gem_path
34
38
  else
35
39
  Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
@@ -9,7 +9,6 @@ module Bundler
9
9
 
10
10
  attr_reader(
11
11
  :dependencies,
12
- :gem_version_promoter,
13
12
  :locked_deps,
14
13
  :locked_gems,
15
14
  :platforms,
@@ -125,25 +124,25 @@ module Bundler
125
124
  @unlock[:gems] = @locked_specs.for(eager_unlock, [], false, false, false).map(&:name)
126
125
  end
127
126
 
128
- @gem_version_promoter = create_gem_version_promoter
129
-
130
127
  @dependency_changes = converge_dependencies
131
128
  @local_changes = converge_locals
132
129
 
133
130
  @requires = compute_requires
134
131
  end
135
132
 
136
- def create_gem_version_promoter
137
- locked_specs =
138
- if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
139
- # Definition uses an empty set of locked_specs to indicate all gems
140
- # are unlocked, but GemVersionPromoter needs the locked_specs
141
- # for conservative comparison.
142
- Bundler::SpecSet.new(@locked_gems.specs)
143
- else
144
- @locked_specs
145
- end
146
- GemVersionPromoter.new(locked_specs, @unlock[:gems])
133
+ def gem_version_promoter
134
+ @gem_version_promoter ||= begin
135
+ locked_specs =
136
+ if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
137
+ # Definition uses an empty set of locked_specs to indicate all gems
138
+ # are unlocked, but GemVersionPromoter needs the locked_specs
139
+ # for conservative comparison.
140
+ Bundler::SpecSet.new(@locked_gems.specs)
141
+ else
142
+ @locked_specs
143
+ end
144
+ GemVersionPromoter.new(locked_specs, @unlock[:gems])
145
+ end
147
146
  end
148
147
 
149
148
  def resolve_with_cache!
@@ -214,7 +213,7 @@ module Bundler
214
213
  @index = nil
215
214
  @resolve = nil
216
215
  @specs = nil
217
- @gem_version_promoter = create_gem_version_promoter
216
+ @gem_version_promoter = nil
218
217
 
219
218
  Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
220
219
  true
@@ -246,22 +245,17 @@ module Bundler
246
245
  def resolve
247
246
  @resolve ||= begin
248
247
  last_resolve = converge_locked_specs
249
- resolve =
250
- if Bundler.frozen_bundle?
251
- Bundler.ui.debug "Frozen, using resolution from the lockfile"
252
- last_resolve
253
- elsif !unlocking? && nothing_changed?
254
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
255
- last_resolve
256
- else
257
- # Run a resolve against the locally available gems
258
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
259
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
260
- end
261
-
262
- # filter out gems that _can_ be installed on multiple platforms, but don't need
263
- # to be
264
- resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
248
+ if Bundler.frozen_bundle?
249
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
250
+ last_resolve
251
+ elsif !unlocking? && nothing_changed?
252
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
253
+ last_resolve
254
+ else
255
+ # Run a resolve against the locally available gems
256
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
257
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
258
+ end
265
259
  end
266
260
  end
267
261
 
@@ -885,7 +879,7 @@ module Bundler
885
879
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
886
880
  next if !remote && !dep.current_platform?
887
881
  platforms = dep.gem_platforms(sorted_platforms)
888
- if platforms.empty?
882
+ if platforms.empty? && !Bundler.settings[:disable_platform_warnings]
889
883
  mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }
890
884
  Bundler.ui.warn \
891
885
  "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
@@ -975,10 +969,10 @@ module Bundler
975
969
 
976
970
  def additional_base_requirements_for_resolve
977
971
  return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
978
- dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
972
+ dependencies_by_name = dependencies.group_by(&:name)
979
973
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
980
974
  name = locked_spec.name
981
- next requirements if @locked_gems.dependencies[name] != dependencies_by_name[name]
975
+ next requirements if @locked_deps[name] != dependencies_by_name[name]
982
976
  dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
983
977
  requirements[name] = DepProxy.new(dep, locked_spec.platform)
984
978
  requirements