bundler 1.17.0.pre.1 → 1.17.0.pre.2

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/README.md +1 -1
  4. data/bundler.gemspec +1 -1
  5. data/lib/bundler.rb +28 -10
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli.rb +33 -5
  8. data/lib/bundler/cli/binstubs.rb +8 -2
  9. data/lib/bundler/cli/remove.rb +18 -0
  10. data/lib/bundler/definition.rb +18 -13
  11. data/lib/bundler/dependency.rb +2 -2
  12. data/lib/bundler/dsl.rb +18 -2
  13. data/lib/bundler/endpoint_specification.rb +1 -1
  14. data/lib/bundler/env.rb +8 -6
  15. data/lib/bundler/fetcher.rb +1 -1
  16. data/lib/bundler/gem_helper.rb +1 -1
  17. data/lib/bundler/injector.rb +156 -8
  18. data/lib/bundler/installer/gem_installer.rb +1 -1
  19. data/lib/bundler/installer/parallel_installer.rb +1 -1
  20. data/lib/bundler/mirror.rb +2 -2
  21. data/lib/bundler/plugin.rb +5 -5
  22. data/lib/bundler/plugin/index.rb +1 -1
  23. data/lib/bundler/resolver/spec_group.rb +0 -4
  24. data/lib/bundler/runtime.rb +1 -1
  25. data/lib/bundler/settings.rb +1 -1
  26. data/lib/bundler/shared_helpers.rb +6 -0
  27. data/lib/bundler/source/metadata.rb +1 -1
  28. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -0
  29. data/lib/bundler/version.rb +1 -1
  30. data/man/bundle-add.1 +1 -1
  31. data/man/bundle-add.1.txt +1 -1
  32. data/man/bundle-binstubs.1 +1 -1
  33. data/man/bundle-binstubs.1.txt +1 -1
  34. data/man/bundle-check.1 +1 -1
  35. data/man/bundle-check.1.txt +1 -1
  36. data/man/bundle-clean.1 +1 -1
  37. data/man/bundle-clean.1.txt +1 -1
  38. data/man/bundle-config.1 +1 -1
  39. data/man/bundle-config.1.txt +1 -1
  40. data/man/bundle-doctor.1 +1 -1
  41. data/man/bundle-doctor.1.txt +1 -1
  42. data/man/bundle-exec.1 +1 -1
  43. data/man/bundle-exec.1.txt +1 -1
  44. data/man/bundle-gem.1 +1 -1
  45. data/man/bundle-gem.1.txt +1 -1
  46. data/man/bundle-info.1 +1 -1
  47. data/man/bundle-info.1.txt +1 -1
  48. data/man/bundle-init.1 +1 -1
  49. data/man/bundle-init.1.txt +1 -1
  50. data/man/bundle-inject.1 +1 -1
  51. data/man/bundle-inject.1.txt +1 -1
  52. data/man/bundle-install.1 +6 -3
  53. data/man/bundle-install.1.txt +118 -107
  54. data/man/bundle-install.ronn +12 -3
  55. data/man/bundle-list.1 +1 -1
  56. data/man/bundle-list.1.txt +1 -1
  57. data/man/bundle-lock.1 +1 -1
  58. data/man/bundle-lock.1.txt +1 -1
  59. data/man/bundle-open.1 +1 -1
  60. data/man/bundle-open.1.txt +1 -1
  61. data/man/bundle-outdated.1 +1 -1
  62. data/man/bundle-outdated.1.txt +1 -1
  63. data/man/bundle-package.1 +1 -1
  64. data/man/bundle-package.1.txt +1 -1
  65. data/man/bundle-platform.1 +1 -1
  66. data/man/bundle-platform.1.txt +1 -1
  67. data/man/bundle-pristine.1 +1 -1
  68. data/man/bundle-pristine.1.txt +1 -1
  69. data/man/bundle-remove.1 +31 -0
  70. data/man/bundle-remove.1.txt +34 -0
  71. data/man/bundle-remove.ronn +23 -0
  72. data/man/bundle-show.1 +1 -1
  73. data/man/bundle-show.1.txt +1 -1
  74. data/man/bundle-update.1 +11 -7
  75. data/man/bundle-update.1.txt +71 -68
  76. data/man/bundle-update.ronn +11 -7
  77. data/man/bundle-viz.1 +1 -1
  78. data/man/bundle-viz.1.txt +1 -1
  79. data/man/bundle.1 +1 -1
  80. data/man/bundle.1.txt +1 -1
  81. data/man/gemfile.5 +1 -1
  82. data/man/gemfile.5.txt +1 -1
  83. data/man/index.txt +1 -0
  84. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8836a89065342b7a101685c55a3bcc17381204df615f228f8440760e355b3bfb
4
- data.tar.gz: bde77176dcf8f419b2b73053659956a694c24e0aebef29267dbd254d29bed1ec
3
+ metadata.gz: 506d0bb8ab812c2d3415e193287e0aadffb4c542a4be6bbe7d6c91750c2c3d4f
4
+ data.tar.gz: 832db1f5894320fc0dc26af468b7da31649e21e8497d7640d0a0e59848faf418
5
5
  SHA512:
6
- metadata.gz: 96b057a613a2831a1a2f27ba8392e17f6b35d213854bd43219897bbc8bfe3db57c54a4e808e45ac2ff636dd615c170ce7764008ec376a5af9070b76e86de680e
7
- data.tar.gz: 688ac2c143586a844b095ce9493b239de94ea6f993d7963ad63c2097e42e714da60bc118a9984b4a6712e6249db85bfa1bd8d24931eac2a37ee4373d30f538bc
6
+ metadata.gz: 2b6ea0407a5b5f9b949777b68365d0ebc743352f7bdfb5a30cb2b7721dca201218a9a8ddfdf1c96656773ef0f89d9c0636f4421f066ede73bf1fac80be3e3324
7
+ data.tar.gz: cd9b08f9ee4c6fd187a65bc5ec9bcfdda6fef7d27fca6f109e4256aa353bb5f1e6b47e3f674c6b476548efd3c5d92eae66042da43310a98984e62ff670c22325
@@ -1,3 +1,19 @@
1
+ ## 1.17.0.pre.2 (2018-10-13)
2
+
3
+ Features:
4
+
5
+ - Configure Bundler home, cache, config and plugin directories with `BUNDLE_USER_HOME`, `BUNDLE_USER_CACHE`, `BUNDLE_USER_CONFIG` and `BUNDLE_USER_PLUGIN` env vars ([#4333](https://github.com/bundler/bundler/issues/4333), @gwerbin)
6
+ - Add `--all` option to `bundle binstubs` that will generate an executable file for all gems with commands in the bundle
7
+ - Add `bundle remove` command to remove gems from the Gemfile via the CLI
8
+ - Improve checking file permissions and asking for `sudo` in Bundler when it doesn't need to
9
+ - Add error message to `bundle add` to check adding duplicate gems to the Gemfile
10
+ - When asking for `sudo`, Bundler will show a list of folders/files that require elevated permissions to write to.
11
+
12
+ 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.
13
+
14
+ - Improve deprecation warning message for `bundle show` command
15
+ - Improve deprecation warning message for the `--force` option in `bundle install`
16
+
1
17
  ## 1.17.0.pre.1 (2018-09-24)
2
18
 
3
19
  Features:
@@ -24,6 +40,28 @@ The following new features are available but are not enabled by default. These a
24
40
  - Use the Gem Version Promoter for major gem updates ([#5993](https://github.com/bundler/bundler/issues/5993), @segiddins)
25
41
  - Add config option to add the Ruby scope to `bundle config path` when configured globally (@segiddins)
26
42
 
43
+ ## 1.16.6 (2018-10-05)
44
+
45
+ Changes:
46
+
47
+ - 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)
48
+ - Add Homepage, Source Code and Chanagelog URI metadata fields to the `bundle gem` gemspec template (@walf443)
49
+
50
+ Bugfixes:
51
+
52
+ - 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)
53
+ - Fix some rescue calls that don't specifiy error type (@utilum)
54
+ - 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)
55
+ - Improve handlding of adding new gems with only a single group to the Gemfile in `bundle add` (@agrim123)
56
+ - Refactor check for OpenSSL in `bundle env` (@voxik)
57
+ - Remove an unnecessary assignment in Metadata (@voxik)
58
+
59
+ Documentation:
60
+
61
+ - 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)
62
+ - Add documentation for the `--all` flag in `bundle update` (@agrim123)
63
+ - Update README to use `bundle add` in usage examples (@hdf1986)
64
+
27
65
  ## 1.16.5 (2018-09-18)
28
66
 
29
67
  Changes:
@@ -40,7 +78,7 @@ Bugfixes:
40
78
  - Check that Bundler::Deprecate is not an autoload constant ([#6163](https://github.com/bundler/bundler/issues/6163), @eregon)
41
79
  - Prefer non-pre-release versions when performing a `bundle update --patch` ([#6684](https://github.com/bundler/bundler/issues/6684), @segiddins)
42
80
 
43
- ## 1.16.4 (2017-08-17)
81
+ ## 1.16.4 (2018-08-17)
44
82
 
45
83
  Changes:
46
84
 
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
- echo 'gem "rspec"' >> Gemfile
27
+ bundle add rspec
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", "Chris Morris", "James Wen", "Tim Moore",
13
+ "David Rodríguez", "Grey Baker", "Stephanie Morillo", "Chris Morris", "James Wen", "Tim Moore",
14
14
  "André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
15
15
  "Yehuda Katz"
16
16
  ]
@@ -191,12 +191,30 @@ module Bundler
191
191
  end
192
192
  tmp_home_path.join(login).tap(&:mkpath)
193
193
  end
194
- rescue => e
194
+ rescue RuntimeError => 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
 
198
- def user_bundle_path
199
- Pathname.new(user_home).join(".bundle")
198
+ def user_bundle_path(dir = "home")
199
+ env_var, fallback = case dir
200
+ when "home"
201
+ ["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")]
202
+ when "cache"
203
+ ["BUNDLE_USER_CACHE", user_bundle_path.join("cache")]
204
+ when "config"
205
+ ["BUNDLE_USER_CONFIG", user_bundle_path.join("config")]
206
+ when "plugin"
207
+ ["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")]
208
+ else
209
+ raise BundlerError, "Unknown user path requested: #{dir}"
210
+ end
211
+ # `fallback` will already be a Pathname, but Pathname.new() is
212
+ # idempotent so it's OK
213
+ Pathname.new(ENV.fetch(env_var, fallback))
214
+ end
215
+
216
+ def user_cache
217
+ user_bundle_path("cache")
200
218
  end
201
219
 
202
220
  def home
@@ -211,10 +229,6 @@ module Bundler
211
229
  bundle_path.join("specifications")
212
230
  end
213
231
 
214
- def user_cache
215
- user_bundle_path.join("cache")
216
- end
217
-
218
232
  def root
219
233
  @root ||= begin
220
234
  SharedHelpers.root
@@ -353,8 +367,12 @@ EOF
353
367
  bin_dir = bin_dir.parent until bin_dir.exist?
354
368
 
355
369
  # if any directory is not writable, we need sudo
356
- files = [path, bin_dir] | Dir[path.join("build_info/*").to_s] | Dir[path.join("*").to_s]
357
- sudo_needed = files.any? {|f| !File.writable?(f) }
370
+ files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
371
+ unwritable_files = files.reject {|f| File.writable?(f) }
372
+ sudo_needed = !unwritable_files.empty?
373
+ if sudo_needed
374
+ Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.sort.map(&:to_s).join("\n ")}"
375
+ end
358
376
  end
359
377
 
360
378
  @requires_sudo_ran = true
@@ -416,7 +434,7 @@ EOF
416
434
 
417
435
  def load_marshal(data)
418
436
  Marshal.load(data)
419
- rescue => e
437
+ rescue StandardError => e
420
438
  raise MarshalError, "#{e.class}: #{e.message}"
421
439
  end
422
440
 
@@ -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-09-23".freeze
8
- @git_commit_sha = "9263a0a3a".freeze
7
+ @built_at = "2018-10-13".freeze
8
+ @git_commit_sha = "0f81f1acd".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -166,6 +166,17 @@ module Bundler
166
166
  Check.new(options).run
167
167
  end
168
168
 
169
+ desc "remove [GEM [GEM ...]]", "Removes gems from the Gemfile"
170
+ long_desc <<-D
171
+ Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
172
+ D
173
+ method_option "install", :type => :boolean, :banner =>
174
+ "Runs 'bundle install' after removing the gems from the Gemfile"
175
+ def remove(*gems)
176
+ require "bundler/cli/remove"
177
+ Remove.new(gems, options).run
178
+ end
179
+
169
180
  desc "install [OPTIONS]", "Install the current environment to the system"
170
181
  long_desc <<-D
171
182
  Install will install all of the gems in the current bundle, making them available
@@ -195,8 +206,7 @@ module Bundler
195
206
  "Do not attempt to fetch gems remotely and use the gem cache instead"
196
207
  deprecated_option "no-cache", :type => :boolean, :banner =>
197
208
  "Don't update the existing gem cache."
198
- method_option "redownload", :type => :boolean, :aliases =>
199
- [Bundler.feature_flag.forget_cli_options? ? nil : "--force"].compact, :banner =>
209
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
200
210
  "Force downloading every gem."
201
211
  deprecated_option "no-prune", :type => :boolean, :banner =>
202
212
  "Don't remove stale gems from the cache."
@@ -219,6 +229,7 @@ module Bundler
219
229
  "Include gems that are part of the specified named group."
220
230
  map "i" => "install"
221
231
  def install
232
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
222
233
  require "bundler/cli/install"
223
234
  Bundler.settings.temporary(:no_install => false) do
224
235
  Install.new(options.dup).run
@@ -245,7 +256,7 @@ module Bundler
245
256
  "Only output warnings and errors."
246
257
  method_option "source", :type => :array, :banner =>
247
258
  "Update a specific source (and all gems associated with it)"
248
- method_option "force", :type => :boolean, :banner =>
259
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
249
260
  "Force downloading every gem."
250
261
  method_option "ruby", :type => :boolean, :banner =>
251
262
  "Update ruby specified in Gemfile.lock"
@@ -264,6 +275,7 @@ module Bundler
264
275
  method_option "all", :type => :boolean, :banner =>
265
276
  "Update everything."
266
277
  def update(*gems)
278
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
267
279
  require "bundler/cli/update"
268
280
  Update.new(options, gems).run
269
281
  end
@@ -278,7 +290,21 @@ module Bundler
278
290
  method_option "outdated", :type => :boolean,
279
291
  :banner => "Show verbose output including whether gems are outdated."
280
292
  def show(gem_name = nil)
281
- Bundler::SharedHelpers.major_deprecation(2, "use `bundle list` instead of `bundle show`") if ARGV[0] == "show"
293
+ if ARGV[0] == "show"
294
+ rest = ARGV[1..-1]
295
+
296
+ new_command = rest.find {|arg| !arg.start_with?("--") } ? "info" : "list"
297
+
298
+ new_arguments = rest.map do |arg|
299
+ next arg if arg != "--paths"
300
+ next "--path" if new_command == "info"
301
+ end
302
+
303
+ old_argv = ARGV.join(" ")
304
+ new_argv = [new_command, *new_arguments.compact].join(" ")
305
+
306
+ Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
307
+ end
282
308
  require "bundler/cli/show"
283
309
  Show.new(options, gem_name).run
284
310
  end
@@ -321,6 +347,8 @@ module Bundler
321
347
  "Specify a different shebang executable name than the default (usually 'ruby')"
322
348
  method_option "standalone", :type => :boolean, :banner =>
323
349
  "Make binstubs that can work without the Bundler runtime"
350
+ method_option "all", :type => :boolean, :banner =>
351
+ "Install binstubs for all gems"
324
352
  def binstubs(*gems)
325
353
  require "bundler/cli/binstubs"
326
354
  Binstubs.new(options, gems).run
@@ -755,7 +783,7 @@ module Bundler
755
783
  end
756
784
 
757
785
  Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}"
758
- rescue
786
+ rescue RuntimeError
759
787
  nil
760
788
  end
761
789
  end
@@ -16,7 +16,13 @@ module Bundler
16
16
  Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
17
17
  installer = Installer.new(Bundler.root, Bundler.definition)
18
18
 
19
- if gems.empty?
19
+ installer_opts = { :force => options[:force], :binstubs_cmd => true }
20
+
21
+ if options[:all]
22
+ raise InvalidOption, "Cannot specify --all with specific gems" unless gems.empty?
23
+ @gems = Bundler.definition.specs.map(&:name)
24
+ installer_opts.delete(:binstubs_cmd)
25
+ elsif gems.empty?
20
26
  Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
21
27
  exit 1
22
28
  end
@@ -35,7 +41,7 @@ module Bundler
35
41
  installer.generate_standalone_bundler_executable_stubs(spec)
36
42
  end
37
43
  else
38
- installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
44
+ installer.generate_bundler_executable_stubs(spec, installer_opts)
39
45
  end
40
46
  end
41
47
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class CLI::Remove
5
+ def initialize(gems, options)
6
+ @gems = gems
7
+ @options = options
8
+ end
9
+
10
+ def run
11
+ raise InvalidOption, "Please specify gems to remove." if @gems.empty?
12
+
13
+ Injector.remove(@gems, {})
14
+
15
+ Installer.install(Bundler.root, Bundler.definition) if @options["install"]
16
+ end
17
+ end
18
+ end
@@ -245,17 +245,22 @@ module Bundler
245
245
  def resolve
246
246
  @resolve ||= begin
247
247
  last_resolve = converge_locked_specs
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
248
+ resolve =
249
+ if Bundler.frozen_bundle?
250
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
251
+ last_resolve
252
+ elsif !unlocking? && nothing_changed?
253
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
254
+ last_resolve
255
+ else
256
+ # Run a resolve against the locally available gems
257
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
258
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
259
+ end
260
+
261
+ # filter out gems that _can_ be installed on multiple platforms, but don't need
262
+ # to be
263
+ resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
259
264
  end
260
265
  end
261
266
 
@@ -969,10 +974,10 @@ module Bundler
969
974
 
970
975
  def additional_base_requirements_for_resolve
971
976
  return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
972
- dependencies_by_name = dependencies.group_by(&:name)
977
+ dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
973
978
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
974
979
  name = locked_spec.name
975
- next requirements if @locked_deps[name] != dependencies_by_name[name]
980
+ next requirements if @locked_gems.dependencies[name] != dependencies_by_name[name]
976
981
  dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
977
982
  requirements[name] = DepProxy.new(dep, locked_spec.platform)
978
983
  requirements
@@ -7,8 +7,7 @@ require "bundler/rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups
11
- attr_reader :platforms
10
+ attr_reader :groups, :platforms, :gemfile
12
11
 
13
12
  PLATFORM_MAP = {
14
13
  :ruby => Gem::Platform::RUBY,
@@ -88,6 +87,7 @@ module Bundler
88
87
  @platforms = Array(options["platforms"])
89
88
  @env = options["env"]
90
89
  @should_include = options.fetch("should_include", true)
90
+ @gemfile = options["gemfile"]
91
91
 
92
92
  @autorequire = Array(options["require"] || []) if options.key?("require")
93
93
  end
@@ -16,7 +16,7 @@ module Bundler
16
16
  VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
17
17
 
18
18
  VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
19
- platform platforms type source install_if].freeze
19
+ platform platforms type source install_if gemfile].freeze
20
20
 
21
21
  attr_reader :gemspecs
22
22
  attr_accessor :dependencies
@@ -93,6 +93,7 @@ module Bundler
93
93
 
94
94
  def gem(name, *args)
95
95
  options = args.last.is_a?(Hash) ? args.pop.dup : {}
96
+ options["gemfile"] = @gemfile
96
97
  version = args || [">= 0"]
97
98
 
98
99
  normalize_options(name, version, options)
@@ -106,13 +107,28 @@ module Bundler
106
107
  if current.requirement != dep.requirement
107
108
  unless deleted_dep
108
109
  return if dep.type == :development
110
+
111
+ update_prompt = ""
112
+
113
+ if File.basename(@gemfile) == Injector::INJECTED_GEMS
114
+ if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
115
+ update_prompt = ". Gem already added"
116
+ else
117
+ update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
118
+
119
+ update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current.requirements_list.include?(">= 0")
120
+ end
121
+ end
122
+
109
123
  raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
110
- "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})"
124
+ "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
125
+ "#{update_prompt}"
111
126
  end
112
127
 
113
128
  else
114
129
  Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
115
130
  "You should probably keep only one of them.\n" \
131
+ "Remove any duplicate entries and specify the gem only once (per group).\n" \
116
132
  "While it's not a problem now, it could cause errors if you change the version of one of them later."
117
133
  end
118
134
 
@@ -123,7 +123,7 @@ module Bundler
123
123
  @required_ruby_version = Gem::Requirement.new(v)
124
124
  end
125
125
  end
126
- rescue => e
126
+ rescue StandardError => e
127
127
  raise GemspecError, "There was an error parsing the metadata for the gem #{name} (#{version}): #{e.class}\n#{e}\nThe metadata was #{data.inspect}"
128
128
  end
129
129
 
@@ -64,7 +64,7 @@ module Bundler
64
64
  Bundler.read_file(filename.to_s).strip
65
65
  rescue Errno::ENOENT
66
66
  "<No #{filename} found>"
67
- rescue => e
67
+ rescue RuntimeError => e
68
68
  "#{e.class}: #{e.message}"
69
69
  end
70
70
 
@@ -110,11 +110,13 @@ module Bundler
110
110
  out << [" Gem Path", ENV.fetch("GEM_PATH") { Gem.path.join(File::PATH_SEPARATOR) }]
111
111
  out << [" User Path", Gem.user_dir]
112
112
  out << [" Bin Dir", Gem.bindir]
113
- out << ["OpenSSL"] if defined?(OpenSSL)
114
- out << [" Compiled", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION)
115
- out << [" Loaded", OpenSSL::OPENSSL_LIBRARY_VERSION] if defined?(OpenSSL::OPENSSL_LIBRARY_VERSION)
116
- out << [" Cert File", OpenSSL::X509::DEFAULT_CERT_FILE] if defined?(OpenSSL::X509::DEFAULT_CERT_FILE)
117
- out << [" Cert Dir", OpenSSL::X509::DEFAULT_CERT_DIR] if defined?(OpenSSL::X509::DEFAULT_CERT_DIR)
113
+ if defined?(OpenSSL)
114
+ out << ["OpenSSL"]
115
+ out << [" Compiled", OpenSSL::OPENSSL_VERSION] if defined?(OpenSSL::OPENSSL_VERSION)
116
+ out << [" Loaded", OpenSSL::OPENSSL_LIBRARY_VERSION] if defined?(OpenSSL::OPENSSL_LIBRARY_VERSION)
117
+ out << [" Cert File", OpenSSL::X509::DEFAULT_CERT_FILE] if defined?(OpenSSL::X509::DEFAULT_CERT_FILE)
118
+ out << [" Cert Dir", OpenSSL::X509::DEFAULT_CERT_DIR] if defined?(OpenSSL::X509::DEFAULT_CERT_DIR)
119
+ end
118
120
  out << ["Tools"]
119
121
  out << [" Git", git_version]
120
122
  out << [" RVM", ENV.fetch("rvm_version") { version_of("rvm") }]