bundler 1.10.6 → 1.11.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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +105 -0
  3. data/.rubocop_todo.yml +120 -0
  4. data/.travis.yml +8 -23
  5. data/CHANGELOG.md +69 -0
  6. data/CODE_OF_CONDUCT.md +6 -4
  7. data/DEVELOPMENT.md +4 -5
  8. data/README.md +2 -2
  9. data/Rakefile +70 -87
  10. data/bin/rake +14 -0
  11. data/bin/rspec +10 -0
  12. data/bin/rubocop +11 -0
  13. data/bundler.gemspec +17 -15
  14. data/exe/bundle +20 -0
  15. data/{bin → exe}/bundle_ruby +6 -4
  16. data/exe/bundler +20 -0
  17. data/lib/bundler.rb +98 -119
  18. data/lib/bundler/capistrano.rb +2 -2
  19. data/lib/bundler/cli.rb +85 -74
  20. data/lib/bundler/cli/binstubs.rb +1 -2
  21. data/lib/bundler/cli/cache.rb +0 -1
  22. data/lib/bundler/cli/check.rb +7 -5
  23. data/lib/bundler/cli/clean.rb +0 -1
  24. data/lib/bundler/cli/common.rb +6 -7
  25. data/lib/bundler/cli/config.rb +69 -56
  26. data/lib/bundler/cli/console.rb +8 -8
  27. data/lib/bundler/cli/exec.rb +4 -3
  28. data/lib/bundler/cli/gem.rb +50 -39
  29. data/lib/bundler/cli/init.rb +5 -6
  30. data/lib/bundler/cli/inject.rb +1 -2
  31. data/lib/bundler/cli/install.rb +18 -21
  32. data/lib/bundler/cli/lock.rb +8 -3
  33. data/lib/bundler/cli/open.rb +4 -5
  34. data/lib/bundler/cli/outdated.rb +7 -8
  35. data/lib/bundler/cli/package.rb +1 -1
  36. data/lib/bundler/cli/platform.rb +2 -3
  37. data/lib/bundler/cli/show.rb +9 -9
  38. data/lib/bundler/cli/update.rb +2 -3
  39. data/lib/bundler/cli/viz.rb +1 -2
  40. data/lib/bundler/constants.rb +1 -1
  41. data/lib/bundler/current_ruby.rb +38 -3
  42. data/lib/bundler/definition.rb +83 -88
  43. data/lib/bundler/dep_proxy.rb +11 -9
  44. data/lib/bundler/dependency.rb +26 -11
  45. data/lib/bundler/deployment.rb +2 -2
  46. data/lib/bundler/deprecate.rb +3 -3
  47. data/lib/bundler/dsl.rb +63 -44
  48. data/lib/bundler/env.rb +19 -12
  49. data/lib/bundler/environment.rb +1 -2
  50. data/lib/bundler/errors.rb +82 -0
  51. data/lib/bundler/fetcher.rb +45 -39
  52. data/lib/bundler/fetcher/base.rb +20 -7
  53. data/lib/bundler/fetcher/dependency.rb +5 -5
  54. data/lib/bundler/fetcher/downloader.rb +1 -2
  55. data/lib/bundler/fetcher/index.rb +4 -7
  56. data/lib/bundler/friendly_errors.rb +15 -8
  57. data/lib/bundler/gem_helper.rb +44 -35
  58. data/lib/bundler/gem_helpers.rb +7 -8
  59. data/lib/bundler/gem_remote_fetcher.rb +41 -0
  60. data/lib/bundler/gem_tasks.rb +4 -1
  61. data/lib/bundler/graph.rb +25 -24
  62. data/lib/bundler/index.rb +21 -18
  63. data/lib/bundler/injector.rb +2 -4
  64. data/lib/bundler/inline.rb +3 -3
  65. data/lib/bundler/installer.rb +57 -144
  66. data/lib/bundler/installer/gem_installer.rb +76 -0
  67. data/lib/bundler/installer/parallel_installer.rb +22 -13
  68. data/lib/bundler/installer/standalone.rb +48 -0
  69. data/lib/bundler/lazy_specification.rb +3 -4
  70. data/lib/bundler/lockfile_parser.rb +21 -19
  71. data/lib/bundler/match_platform.rb +4 -4
  72. data/lib/bundler/psyched_yaml.rb +3 -3
  73. data/lib/bundler/remote_specification.rb +1 -1
  74. data/lib/bundler/resolver.rb +93 -88
  75. data/lib/bundler/retry.rb +9 -10
  76. data/lib/bundler/ruby_dsl.rb +1 -1
  77. data/lib/bundler/ruby_version.rb +7 -10
  78. data/lib/bundler/rubygems_ext.rb +32 -27
  79. data/lib/bundler/{gem_installer.rb → rubygems_gem_installer.rb} +2 -2
  80. data/lib/bundler/rubygems_integration.rb +85 -70
  81. data/lib/bundler/runtime.rb +57 -61
  82. data/lib/bundler/settings.rb +27 -26
  83. data/lib/bundler/setup.rb +3 -3
  84. data/lib/bundler/shared_helpers.rb +45 -20
  85. data/lib/bundler/similarity_detector.rb +19 -21
  86. data/lib/bundler/source.rb +4 -5
  87. data/lib/bundler/source/git.rb +29 -31
  88. data/lib/bundler/source/git/git_proxy.rb +52 -26
  89. data/lib/bundler/source/path.rb +25 -28
  90. data/lib/bundler/source/path/installer.rb +4 -4
  91. data/lib/bundler/source/rubygems.rb +62 -48
  92. data/lib/bundler/source/rubygems/remote.rb +3 -3
  93. data/lib/bundler/source_list.rb +4 -4
  94. data/lib/bundler/spec_set.rb +17 -15
  95. data/lib/bundler/ssl_certs/certificate_manager.rb +5 -6
  96. data/lib/bundler/stub_specification.rb +2 -2
  97. data/lib/bundler/templates/Executable +5 -5
  98. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +42 -6
  99. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  100. data/lib/bundler/templates/newgem/Rakefile.tt +4 -2
  101. data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
  102. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  103. data/lib/bundler/ui.rb +3 -3
  104. data/lib/bundler/ui/rg_proxy.rb +2 -2
  105. data/lib/bundler/ui/shell.rb +10 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +82 -71
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +9 -0
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +40 -21
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -0
  111. data/lib/bundler/vendored_molinillo.rb +1 -1
  112. data/lib/bundler/vendored_persistent.rb +3 -3
  113. data/lib/bundler/vendored_thor.rb +2 -2
  114. data/lib/bundler/version.rb +1 -1
  115. data/lib/bundler/vlad.rb +1 -1
  116. data/lib/bundler/worker.rb +4 -5
  117. data/man/bundle-config.ronn +4 -2
  118. data/man/bundle-gem.ronn +77 -0
  119. data/man/bundle-install.ronn +13 -6
  120. data/man/bundle-lock.ronn +47 -0
  121. data/man/bundle.ronn +1 -1
  122. data/man/gemfile.5.ronn +8 -0
  123. data/man/index.txt +1 -0
  124. metadata +37 -8
  125. data/bin/bundle +0 -21
  126. data/bin/bundler +0 -21
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Exit cleanly from an early interrupt
4
+ Signal.trap("INT") { exit 1 }
5
+
6
+ require "bundler"
7
+ # Check if an older version of bundler is installed
8
+ $LOAD_PATH.each do |path|
9
+ next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
10
+ err = "Looks like you have a version of bundler that's older than 0.9.\n"
11
+ err << "Please remove your old versions.\n"
12
+ err << "An easy way to do this is by running `gem cleanup bundler`."
13
+ abort(err)
14
+ end
15
+
16
+ require "bundler/friendly_errors"
17
+ Bundler.with_friendly_errors do
18
+ require "bundler/cli"
19
+ Bundler::CLI.start(ARGV, :debug => true)
20
+ end
@@ -1,89 +1,54 @@
1
- require 'fileutils'
2
- require 'pathname'
3
- require 'rbconfig'
4
- require 'bundler/gem_path_manipulation'
5
- require 'bundler/rubygems_ext'
6
- require 'bundler/rubygems_integration'
7
- require 'bundler/version'
8
- require 'bundler/constants'
9
- require 'bundler/current_ruby'
1
+ require "fileutils"
2
+ require "pathname"
3
+ require "rbconfig"
4
+ require "thread"
5
+ require "bundler/gem_path_manipulation"
6
+ require "bundler/gem_remote_fetcher"
7
+ require "bundler/rubygems_ext"
8
+ require "bundler/rubygems_integration"
9
+ require "bundler/version"
10
+ require "bundler/constants"
11
+ require "bundler/current_ruby"
12
+ require "bundler/errors"
10
13
 
11
14
  module Bundler
12
15
  preserve_gem_path
13
16
  ORIGINAL_ENV = ENV.to_hash
14
-
15
- autoload :Definition, 'bundler/definition'
16
- autoload :Dependency, 'bundler/dependency'
17
- autoload :DepProxy, 'bundler/dep_proxy'
18
- autoload :Deprecate, 'bundler/deprecate'
19
- autoload :Dsl, 'bundler/dsl'
20
- autoload :EndpointSpecification, 'bundler/endpoint_specification'
21
- autoload :Environment, 'bundler/environment'
22
- autoload :Env, 'bundler/env'
23
- autoload :Fetcher, 'bundler/fetcher'
24
- autoload :GemHelper, 'bundler/gem_helper'
25
- autoload :GemHelpers, 'bundler/gem_helpers'
26
- autoload :GemInstaller, 'bundler/gem_installer'
27
- autoload :Graph, 'bundler/graph'
28
- autoload :Index, 'bundler/index'
29
- autoload :Installer, 'bundler/installer'
30
- autoload :Injector, 'bundler/injector'
31
- autoload :LazySpecification, 'bundler/lazy_specification'
32
- autoload :LockfileParser, 'bundler/lockfile_parser'
33
- autoload :MatchPlatform, 'bundler/match_platform'
34
- autoload :RemoteSpecification, 'bundler/remote_specification'
35
- autoload :Resolver, 'bundler/resolver'
36
- autoload :Retry, 'bundler/retry'
37
- autoload :RubyVersion, 'bundler/ruby_version'
38
- autoload :RubyDsl, 'bundler/ruby_dsl'
39
- autoload :Runtime, 'bundler/runtime'
40
- autoload :Settings, 'bundler/settings'
41
- autoload :SharedHelpers, 'bundler/shared_helpers'
42
- autoload :SpecSet, 'bundler/spec_set'
43
- autoload :StubSpecification, 'bundler/stub_specification'
44
- autoload :Source, 'bundler/source'
45
- autoload :SourceList, 'bundler/source_list'
46
- autoload :Specification, 'bundler/shared_helpers'
47
- autoload :SystemRubyVersion, 'bundler/ruby_version'
48
- autoload :UI, 'bundler/ui'
49
-
50
- class BundlerError < StandardError
51
- def self.status_code(code)
52
- define_method(:status_code) { code }
53
- end
54
- end
55
-
56
- class GemfileNotFound < BundlerError; status_code(10) ; end
57
- class GemNotFound < BundlerError; status_code(7) ; end
58
- class GemfileError < BundlerError; status_code(4) ; end
59
- class InstallError < BundlerError; status_code(5) ; end
60
- class InstallHookError < BundlerError; status_code(8) ; end
61
- class PathError < BundlerError; status_code(13) ; end
62
- class GitError < BundlerError; status_code(11) ; end
63
- class DeprecatedError < BundlerError; status_code(12) ; end
64
- class GemspecError < BundlerError; status_code(14) ; end
65
- class InvalidOption < BundlerError; status_code(15) ; end
66
- class ProductionError < BundlerError; status_code(16) ; end
67
- class HTTPError < BundlerError; status_code(17) ; end
68
- class RubyVersionMismatch < BundlerError; status_code(18) ; end
69
- class SecurityError < BundlerError; status_code(19) ; end
70
- class LockfileError < BundlerError; status_code(20) ; end
71
- class CyclicDependencyError < BundlerError; status_code(21) ; end
72
- class GemfileLockNotFound < BundlerError; status_code(22) ; end
73
-
74
- # Internal errors, should be rescued
75
- class VersionConflict < BundlerError
76
- attr_reader :conflicts
77
-
78
- def initialize(conflicts, msg = nil)
79
- super(msg)
80
- @conflicts = conflicts
81
- end
82
-
83
- status_code(6)
84
- end
85
-
86
- class MarshalError < StandardError; end
17
+ SUDO_MUTEX = Mutex.new
18
+
19
+ autoload :Definition, "bundler/definition"
20
+ autoload :Dependency, "bundler/dependency"
21
+ autoload :DepProxy, "bundler/dep_proxy"
22
+ autoload :Deprecate, "bundler/deprecate"
23
+ autoload :Dsl, "bundler/dsl"
24
+ autoload :EndpointSpecification, "bundler/endpoint_specification"
25
+ autoload :Environment, "bundler/environment"
26
+ autoload :Env, "bundler/env"
27
+ autoload :Fetcher, "bundler/fetcher"
28
+ autoload :GemHelper, "bundler/gem_helper"
29
+ autoload :GemHelpers, "bundler/gem_helpers"
30
+ autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
31
+ autoload :Graph, "bundler/graph"
32
+ autoload :Index, "bundler/index"
33
+ autoload :Installer, "bundler/installer"
34
+ autoload :Injector, "bundler/injector"
35
+ autoload :LazySpecification, "bundler/lazy_specification"
36
+ autoload :LockfileParser, "bundler/lockfile_parser"
37
+ autoload :MatchPlatform, "bundler/match_platform"
38
+ autoload :RemoteSpecification, "bundler/remote_specification"
39
+ autoload :Resolver, "bundler/resolver"
40
+ autoload :Retry, "bundler/retry"
41
+ autoload :RubyVersion, "bundler/ruby_version"
42
+ autoload :RubyDsl, "bundler/ruby_dsl"
43
+ autoload :Runtime, "bundler/runtime"
44
+ autoload :Settings, "bundler/settings"
45
+ autoload :SharedHelpers, "bundler/shared_helpers"
46
+ autoload :SpecSet, "bundler/spec_set"
47
+ autoload :StubSpecification, "bundler/stub_specification"
48
+ autoload :Source, "bundler/source"
49
+ autoload :SourceList, "bundler/source_list"
50
+ autoload :SystemRubyVersion, "bundler/ruby_version"
51
+ autoload :UI, "bundler/ui"
87
52
 
88
53
  class << self
89
54
  attr_writer :bundle_path
@@ -111,7 +76,7 @@ module Bundler
111
76
  @bin_path ||= begin
112
77
  path = settings[:bin] || "bin"
113
78
  path = Pathname.new(path).expand_path(root).expand_path
114
- FileUtils.mkdir_p(path)
79
+ SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
115
80
  path
116
81
  end
117
82
  end
@@ -201,14 +166,16 @@ module Bundler
201
166
  end
202
167
 
203
168
  def app_config_path
204
- ENV['BUNDLE_APP_CONFIG'] ?
205
- Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) :
206
- root.join('.bundle')
169
+ if ENV["BUNDLE_APP_CONFIG"]
170
+ Pathname.new(ENV["BUNDLE_APP_CONFIG"]).expand_path(root)
171
+ else
172
+ root.join(".bundle")
173
+ end
207
174
  end
208
175
 
209
176
  def app_cache(custom_path = nil)
210
177
  path = custom_path || root
211
- path.join(self.settings.app_cache_path)
178
+ path.join(settings.app_cache_path)
212
179
  end
213
180
 
214
181
  def tmp(name = Process.pid.to_s)
@@ -236,12 +203,19 @@ module Bundler
236
203
 
237
204
  def with_clean_env
238
205
  with_original_env do
239
- ENV['MANPATH'] = ENV['BUNDLE_ORIG_MANPATH']
240
- ENV.delete_if { |k,_| k[0,7] == 'BUNDLE_' }
241
- if ENV.has_key? 'RUBYOPT'
242
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
243
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
206
+ ENV["MANPATH"] = ENV["BUNDLE_ORIG_MANPATH"]
207
+ ENV.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
208
+
209
+ if ENV.key?("RUBYOPT")
210
+ ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-rbundler/setup", ""
244
211
  end
212
+
213
+ if ENV.key?("RUBYLIB")
214
+ rubylib = ENV["RUBYLIB"].split(File::PATH_SEPARATOR)
215
+ rubylib.delete(File.expand_path("..", __FILE__))
216
+ ENV["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
217
+ end
218
+
245
219
  yield
246
220
  end
247
221
  end
@@ -278,9 +252,7 @@ module Bundler
278
252
  def requires_sudo?
279
253
  return @requires_sudo if defined?(@requires_sudo_ran)
280
254
 
281
- if settings.allow_sudo?
282
- sudo_present = which "sudo"
283
- end
255
+ sudo_present = which "sudo" if settings.allow_sudo?
284
256
 
285
257
  if sudo_present
286
258
  # the bundle path and subdirectories need to be writable for Rubygems
@@ -293,8 +265,8 @@ module Bundler
293
265
  bin_dir = bin_dir.parent until bin_dir.exist?
294
266
 
295
267
  # if any directory is not writable, we need sudo
296
- files = [path, bin_dir] | Dir[path.join('build_info/*').to_s] | Dir[path.join('*').to_s]
297
- sudo_needed = files.any?{|f| !File.writable?(f) }
268
+ files = [path, bin_dir] | Dir[path.join("build_info/*").to_s] | Dir[path.join("*").to_s]
269
+ sudo_needed = files.any? {|f| !File.writable?(f) }
298
270
  end
299
271
 
300
272
  @requires_sudo_ran = true
@@ -305,15 +277,17 @@ module Bundler
305
277
  if requires_sudo?
306
278
  sudo "mkdir -p '#{path}'" unless File.exist?(path)
307
279
  else
308
- FileUtils.mkdir_p(path)
280
+ SharedHelpers.filesystem_access(path, :write) do |p|
281
+ FileUtils.mkdir_p(p)
282
+ end
309
283
  end
310
284
  end
311
285
 
312
286
  def which(executable)
313
287
  if File.file?(executable) && File.executable?(executable)
314
288
  executable
315
- elsif ENV['PATH']
316
- path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
289
+ elsif ENV["PATH"]
290
+ path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |p|
317
291
  abs_path = File.join(p, executable)
318
292
  File.file?(abs_path) && File.executable?(abs_path)
319
293
  end
@@ -322,23 +296,25 @@ module Bundler
322
296
  end
323
297
 
324
298
  def sudo(str)
325
- prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, '').strip + " "
326
- Your user account isn't allowed to install to the system Rubygems.
327
- You can cancel this installation and run:
299
+ SUDO_MUTEX.synchronize do
300
+ prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
301
+ Your user account isn't allowed to install to the system Rubygems.
302
+ You can cancel this installation and run:
328
303
 
329
- bundle install --path vendor/bundle
304
+ bundle install --path vendor/bundle
330
305
 
331
- to install the gems into ./vendor/bundle/, or you can enter your password
332
- and install the bundled gems to Rubygems using sudo.
306
+ to install the gems into ./vendor/bundle/, or you can enter your password
307
+ and install the bundled gems to Rubygems using sudo.
333
308
 
334
- Password:
335
- PROMPT
309
+ Password:
310
+ PROMPT
336
311
 
337
- `sudo -p "#{prompt}" #{str}`
312
+ `sudo -p "#{prompt}" #{str}`
313
+ end
338
314
  end
339
315
 
340
316
  def read_file(file)
341
- File.open(file, "rb") { |f| f.read }
317
+ File.open(file, "rb", &:read)
342
318
  end
343
319
 
344
320
  def load_marshal(data)
@@ -371,7 +347,7 @@ module Bundler
371
347
  spec
372
348
  end
373
349
  rescue Gem::InvalidSpecificationException => e
374
- Bundler.ui.warn "The gemspec at #{file} is not valid. " \
350
+ UI::Shell.new.warn "The gemspec at #{file} is not valid. " \
375
351
  "The validation error was '#{e.message}'"
376
352
  nil
377
353
  end
@@ -406,8 +382,8 @@ module Bundler
406
382
  def eval_gemspec(path, contents)
407
383
  eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
408
384
  rescue ScriptError, StandardError => e
409
- original_line = e.backtrace.find { |line| line.include?(path.to_s) }
410
- msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
385
+ original_line = e.backtrace.find {|line| line.include?(path.to_s) }
386
+ msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
411
387
  msg << " from\n #{original_line}" if original_line
412
388
  msg << "\n"
413
389
 
@@ -419,12 +395,12 @@ module Bundler
419
395
  end
420
396
 
421
397
  def configure_gem_home_and_path
422
- blank_home = ENV['GEM_HOME'].nil? || ENV['GEM_HOME'].empty?
398
+ blank_home = ENV["GEM_HOME"].nil? || ENV["GEM_HOME"].empty?
423
399
  if settings[:disable_shared_gems]
424
- ENV['GEM_PATH'] = ''
400
+ ENV["GEM_PATH"] = ""
425
401
  elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s
426
402
  possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
427
- paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
403
+ paths = possibles.flatten.compact.uniq.reject(&:empty?)
428
404
  ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
429
405
  end
430
406
 
@@ -434,9 +410,13 @@ module Bundler
434
410
 
435
411
  def configure_gem_home
436
412
  # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
437
- FileUtils.mkdir_p bundle_path.to_s rescue nil
413
+ begin
414
+ FileUtils.mkdir_p bundle_path.to_s
415
+ rescue
416
+ nil
417
+ end
438
418
 
439
- ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
419
+ ENV["GEM_HOME"] = File.expand_path(bundle_path, root)
440
420
  Bundler.rubygems.clear_paths
441
421
  end
442
422
 
@@ -447,6 +427,5 @@ module Bundler
447
427
  lockfile.rmtree
448
428
  end
449
429
  end
450
-
451
430
  end
452
431
  end
@@ -2,8 +2,8 @@
2
2
  #
3
3
  # Just add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
4
4
  # Bundler will be activated after each new deployment.
5
- require 'bundler/deployment'
6
- require 'capistrano/version'
5
+ require "bundler/deployment"
6
+ require "capistrano/version"
7
7
 
8
8
  if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0")
9
9
  raise "For Capistrano 3.x integration, please use http://github.com/capistrano/bundler"
@@ -1,10 +1,10 @@
1
- require 'bundler'
2
- require 'bundler/vendored_thor'
1
+ require "bundler"
2
+ require "bundler/vendored_thor"
3
3
 
4
4
  module Bundler
5
5
  class CLI < Thor
6
6
  include Thor::Actions
7
- AUTO_INSTALL_CMDS = %w[show binstubs outdated exec open console licenses clean]
7
+ AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean)
8
8
 
9
9
  def self.start(*)
10
10
  super
@@ -17,7 +17,7 @@ module Bundler
17
17
  super
18
18
 
19
19
  custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
20
- ENV['BUNDLE_GEMFILE'] = File.expand_path(custom_gemfile) if custom_gemfile
20
+ ENV["BUNDLE_GEMFILE"] = File.expand_path(custom_gemfile) if custom_gemfile && !custom_gemfile.empty?
21
21
 
22
22
  Bundler.settings[:retry] = options[:retry] if options[:retry]
23
23
 
@@ -29,6 +29,13 @@ module Bundler
29
29
  self.options ||= {}
30
30
  Bundler.ui = UI::Shell.new(options)
31
31
  Bundler.ui.level = "debug" if options["verbose"]
32
+
33
+ if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty?
34
+ Bundler.ui.warn(
35
+ "The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \
36
+ "experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \
37
+ "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true)
38
+ end
32
39
  end
33
40
 
34
41
  check_unknown_options!(:except => [:config, :exec])
@@ -37,8 +44,8 @@ module Bundler
37
44
  default_task :install
38
45
  class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
39
46
  class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
40
- :desc => "Specify the number of times you wish to attempt network commands"
41
- class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
47
+ :desc => "Specify the number of times you wish to attempt network commands"
48
+ class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
42
49
 
43
50
  def help(cli = nil)
44
51
  case cli
@@ -48,14 +55,15 @@ module Bundler
48
55
  end
49
56
 
50
57
  manpages = %w(
51
- bundle
52
- bundle-config
53
- bundle-exec
54
- bundle-install
55
- bundle-package
56
- bundle-update
57
- bundle-platform
58
- gemfile.5)
58
+ bundle
59
+ bundle-config
60
+ bundle-exec
61
+ bundle-gem
62
+ bundle-install
63
+ bundle-package
64
+ bundle-update
65
+ bundle-platform
66
+ gemfile.5)
59
67
 
60
68
  if manpages.include?(command)
61
69
  root = File.expand_path("../man", __FILE__)
@@ -65,6 +73,8 @@ module Bundler
65
73
  else
66
74
  puts File.read("#{root}/#{command}.txt")
67
75
  end
76
+ elsif command_path = Bundler.which("bundler-#{cli}")
77
+ Kernel.exec(command_path, "--help")
68
78
  else
69
79
  super
70
80
  end
@@ -84,7 +94,7 @@ module Bundler
84
94
  D
85
95
  method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
86
96
  def init
87
- require 'bundler/cli/init'
97
+ require "bundler/cli/init"
88
98
  Init.new(options.dup).run
89
99
  end
90
100
 
@@ -102,7 +112,7 @@ module Bundler
102
112
  "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
103
113
  map "c" => "check"
104
114
  def check
105
- require 'bundler/cli/check'
115
+ require "bundler/cli/check"
106
116
  Check.new(options).run
107
117
  end
108
118
 
@@ -151,14 +161,14 @@ module Bundler
151
161
  "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
152
162
  method_option "trust-policy", :alias => "P", :type => :string, :banner =>
153
163
  "Gem trust policy (like gem install -P). Must be one of " +
154
- Bundler.rubygems.security_policy_keys.join('|')
164
+ Bundler.rubygems.security_policy_keys.join("|")
155
165
  method_option "without", :type => :array, :banner =>
156
166
  "Exclude gems that are part of the specified named group."
157
167
  method_option "with", :type => :array, :banner =>
158
168
  "Include gems that are part of the specified named group."
159
169
  map "i" => "install"
160
170
  def install
161
- require 'bundler/cli/install'
171
+ require "bundler/cli/install"
162
172
  Install.new(options.dup).run
163
173
  end
164
174
 
@@ -183,7 +193,7 @@ module Bundler
183
193
  method_option "force", :type => :boolean, :banner =>
184
194
  "Force downloading every gem."
185
195
  def update(*gems)
186
- require 'bundler/cli/update'
196
+ require "bundler/cli/update"
187
197
  Update.new(options, gems).run
188
198
  end
189
199
 
@@ -193,11 +203,11 @@ module Bundler
193
203
  Calling show with [GEM] will list the exact location of that gem on your machine.
194
204
  D
195
205
  method_option "paths", :type => :boolean,
196
- :banner => "List the paths of all gems that are required by your Gemfile."
206
+ :banner => "List the paths of all gems that are required by your Gemfile."
197
207
  method_option "outdated", :type => :boolean,
198
- :banner => "Show verbose output including whether gems are outdated."
208
+ :banner => "Show verbose output including whether gems are outdated."
199
209
  def show(gem_name = nil)
200
- require 'bundler/cli/show'
210
+ require "bundler/cli/show"
201
211
  Show.new(options, gem_name).run
202
212
  end
203
213
  map %w(list) => "show"
@@ -205,14 +215,15 @@ module Bundler
205
215
  desc "binstubs GEM [OPTIONS]", "Install the binstubs of the listed gem"
206
216
  long_desc <<-D
207
217
  Generate binstubs for executables in [GEM]. Binstubs are put into bin,
208
- or the --binstubs directory if one has been set.
218
+ or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
219
+ will create binstubs for all given gems.
209
220
  D
210
221
  method_option "force", :type => :boolean, :default => false, :banner =>
211
222
  "Overwrite existing binstubs if they exist"
212
223
  method_option "path", :type => :string, :lazy_default => "bin", :banner =>
213
224
  "Binstub destination directory (default bin)"
214
225
  def binstubs(*gems)
215
- require 'bundler/cli/binstubs'
226
+ require "bundler/cli/binstubs"
216
227
  Binstubs.new(options, gems).run
217
228
  end
218
229
 
@@ -230,16 +241,16 @@ module Bundler
230
241
  method_option "strict", :type => :boolean, :banner =>
231
242
  "Only list newer versions allowed by your Gemfile requirements"
232
243
  def outdated(*gems)
233
- require 'bundler/cli/outdated'
244
+ require "bundler/cli/outdated"
234
245
  Outdated.new(options, gems).run
235
246
  end
236
247
 
237
248
  desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true
238
249
  method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)."
239
250
  method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms, not just the current one"
240
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
251
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
241
252
  def cache
242
- require 'bundler/cli/cache'
253
+ require "bundler/cli/cache"
243
254
  Cache.new(options).run
244
255
  end
245
256
 
@@ -249,8 +260,8 @@ module Bundler
249
260
  method_option "cache-path", :type => :string, :banner =>
250
261
  "Specify a different cache path than the default (vendor/cache)."
251
262
  method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
252
- method_option "no-install", :type => :boolean, :banner => "Don't actually install the gems, just package."
253
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
263
+ method_option "no-install", :type => :boolean, :banner => "Don't actually install the gems, just package."
264
+ method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
254
265
  method_option "path", :type => :string, :banner =>
255
266
  "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
256
267
  method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
@@ -261,7 +272,7 @@ module Bundler
261
272
  bundle without having to download any additional gems.
262
273
  D
263
274
  def package
264
- require 'bundler/cli/package'
275
+ require "bundler/cli/package"
265
276
  Package.new(options).run
266
277
  end
267
278
  map %w(pack) => :package
@@ -275,7 +286,7 @@ module Bundler
275
286
  D
276
287
  map "e" => "exec"
277
288
  def exec(*args)
278
- require 'bundler/cli/exec'
289
+ require "bundler/cli/exec"
279
290
  Exec.new(options, args).run
280
291
  end
281
292
 
@@ -292,19 +303,19 @@ module Bundler
292
303
  where they were specified.
293
304
  D
294
305
  def config(*args)
295
- require 'bundler/cli/config'
306
+ require "bundler/cli/config"
296
307
  Config.new(options, args, self).run
297
308
  end
298
309
 
299
310
  desc "open GEM", "Opens the source directory of the given bundled gem"
300
311
  def open(name)
301
- require 'bundler/cli/open'
312
+ require "bundler/cli/open"
302
313
  Open.new(options, name).run
303
314
  end
304
315
 
305
316
  desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
306
317
  def console(group = nil)
307
- require 'bundler/cli/console'
318
+ require "bundler/cli/console"
308
319
  Console.new(options, group).run
309
320
  end
310
321
 
@@ -316,7 +327,7 @@ module Bundler
316
327
 
317
328
  desc "licenses", "Prints the license of all gems in the bundle"
318
329
  def licenses
319
- Bundler.load.specs.sort_by { |s| s.license.to_s }.reverse.each do |s|
330
+ Bundler.load.specs.sort_by {|s| s.license.to_s }.reverse_each do |s|
320
331
  gem_name = s.name
321
332
  license = s.license || s.licenses
322
333
 
@@ -328,39 +339,39 @@ module Bundler
328
339
  end
329
340
  end
330
341
 
331
- desc 'viz [OPTIONS]', "Generates a visual dependency graph"
342
+ desc "viz [OPTIONS]", "Generates a visual dependency graph"
332
343
  long_desc <<-D
333
344
  Viz generates a PNG file of the current Gemfile as a dependency graph.
334
345
  Viz requires the ruby-graphviz gem (and its dependencies).
335
346
  The associated gems must also be installed via 'bundle install'.
336
347
  D
337
- method_option :file, :type => :string, :default => 'gem_graph', :aliases => '-f', :banner => "The name to use for the generated file. see format option"
338
- method_option :format, :type => :string, :default => "png", :aliases => '-F', :banner => "This is output format option. Supported format is png, jpg, svg, dot ..."
339
- method_option :requirements, :type => :boolean, :default => false, :aliases => '-r', :banner => "Set to show the version of each required dependency."
340
- method_option :version, :type => :boolean, :default => false, :aliases => '-v', :banner => "Set to show each gem version."
348
+ method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :banner => "The name to use for the generated file. see format option"
349
+ method_option :format, :type => :string, :default => "png", :aliases => "-F", :banner => "This is output format option. Supported format is png, jpg, svg, dot ..."
350
+ method_option :requirements, :type => :boolean, :default => false, :aliases => "-r", :banner => "Set to show the version of each required dependency."
351
+ method_option :version, :type => :boolean, :default => false, :aliases => "-v", :banner => "Set to show each gem version."
341
352
  method_option :without, :type => :array, :default => [], :banner => "Exclude gems that are part of the specified named group."
342
353
  def viz
343
- require 'bundler/cli/viz'
354
+ require "bundler/cli/viz"
344
355
  Viz.new(options).run
345
356
  end
346
357
 
347
358
  desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem"
348
- method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :desc => "Generate a binary for your library."
359
+ method_option :bin, :type => :boolean, :default => false, :aliases => "-b", :desc => "Generate a binary for your library."
349
360
  method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config gem.coc true`."
350
361
  method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
351
- :lazy_default => [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? },
352
- :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
362
+ :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
363
+ :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
353
364
  method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
354
365
  method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config gem.mit true`."
355
- method_option :test, :type => :string, :lazy_default => 'rspec', :aliases => '-t', :banner => "rspec",
356
- :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config gem.test rspec`."
366
+ method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
367
+ :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config gem.test rspec`."
357
368
  def gem(name)
358
- require 'bundler/cli/gem'
369
+ require "bundler/cli/gem"
359
370
  Gem.new(options, name, self).run
360
371
  end
361
372
 
362
373
  def self.source_root
363
- File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
374
+ File.expand_path(File.join(File.dirname(__FILE__), "templates"))
364
375
  end
365
376
 
366
377
  desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory"
@@ -369,7 +380,7 @@ module Bundler
369
380
  method_option "force", :type => :boolean, :default => false, :banner =>
370
381
  "Forces clean even if --path is not set"
371
382
  def clean
372
- require 'bundler/cli/clean'
383
+ require "bundler/cli/clean"
373
384
  Clean.new(options.dup).run
374
385
  end
375
386
 
@@ -377,19 +388,19 @@ module Bundler
377
388
  method_option "ruby", :type => :boolean, :default => false, :banner =>
378
389
  "only display ruby related platform information"
379
390
  def platform
380
- require 'bundler/cli/platform'
391
+ require "bundler/cli/platform"
381
392
  Platform.new(options).run
382
393
  end
383
394
 
384
395
  desc "inject GEM VERSION ...", "Add the named gem(s), with version requirements, to the resolved Gemfile"
385
396
  def inject(name, version, *gems)
386
- require 'bundler/cli/inject'
397
+ require "bundler/cli/inject"
387
398
  Inject.new(options, name, version, gems).run
388
399
  end
389
400
 
390
401
  desc "lock", "Creates a lockfile without installing"
391
- method_option "update", :type => :boolean, :default => false, :banner =>
392
- "ignore the existing lockfile"
402
+ method_option "update", :type => :array, :lazy_default => [], :banner =>
403
+ "ignore the existing lockfile, update all gems by default, or update list of given gems"
393
404
  method_option "local", :type => :boolean, :default => false, :banner =>
394
405
  "do not attempt to fetch remote gemspecs and use the local gem cache only"
395
406
  method_option "print", :type => :boolean, :default => false, :banner =>
@@ -397,7 +408,7 @@ module Bundler
397
408
  method_option "lockfile", :type => :string, :default => nil, :banner =>
398
409
  "the path the lockfile should be written to"
399
410
  def lock
400
- require 'bundler/cli/lock'
411
+ require "bundler/cli/lock"
401
412
  Lock.new(options).run
402
413
  end
403
414
 
@@ -406,26 +417,26 @@ module Bundler
406
417
  Env.new.write($stdout)
407
418
  end
408
419
 
409
- private
410
-
411
- # Automatically invoke `bundle install` and resume if
412
- # Bundler.settings[:auto_install] exists. This is set through config cmd
413
- # `bundle config auto_install 1`.
414
- #
415
- # Note that this method `nil`s out the global Definition object, so it
416
- # should be called first, before you instantiate anything like an
417
- # `Installer` that'll keep a reference to the old one instead.
418
- def auto_install
419
- return unless Bundler.settings[:auto_install]
420
-
421
- begin
422
- Bundler.definition.specs
423
- rescue GemNotFound
424
- Bundler.ui.info "Automatically installing missing gems."
425
- Bundler.reset!
426
- invoke :install, []
427
- Bundler.reset!
428
- end
420
+ private
421
+
422
+ # Automatically invoke `bundle install` and resume if
423
+ # Bundler.settings[:auto_install] exists. This is set through config cmd
424
+ # `bundle config auto_install 1`.
425
+ #
426
+ # Note that this method `nil`s out the global Definition object, so it
427
+ # should be called first, before you instantiate anything like an
428
+ # `Installer` that'll keep a reference to the old one instead.
429
+ def auto_install
430
+ return unless Bundler.settings[:auto_install]
431
+
432
+ begin
433
+ Bundler.definition.specs
434
+ rescue GemNotFound
435
+ Bundler.ui.info "Automatically installing missing gems."
436
+ Bundler.reset!
437
+ invoke :install, []
438
+ Bundler.reset!
429
439
  end
440
+ end
430
441
  end
431
442
  end