bundler 1.10.6 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +105 -0
- data/.rubocop_todo.yml +120 -0
- data/.travis.yml +8 -23
- data/CHANGELOG.md +95 -0
- data/CODE_OF_CONDUCT.md +6 -4
- data/DEVELOPMENT.md +4 -5
- data/README.md +2 -2
- data/Rakefile +71 -88
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +17 -15
- data/exe/bundle +20 -0
- data/{bin → exe}/bundle_ruby +6 -4
- data/exe/bundler +20 -0
- data/lib/bundler/capistrano.rb +2 -2
- data/lib/bundler/cli/binstubs.rb +1 -2
- data/lib/bundler/cli/cache.rb +0 -1
- data/lib/bundler/cli/check.rb +7 -5
- data/lib/bundler/cli/clean.rb +0 -1
- data/lib/bundler/cli/common.rb +6 -7
- data/lib/bundler/cli/config.rb +69 -56
- data/lib/bundler/cli/console.rb +8 -8
- data/lib/bundler/cli/exec.rb +5 -4
- data/lib/bundler/cli/gem.rb +52 -40
- data/lib/bundler/cli/init.rb +5 -6
- data/lib/bundler/cli/inject.rb +1 -2
- data/lib/bundler/cli/install.rb +18 -21
- data/lib/bundler/cli/lock.rb +8 -3
- data/lib/bundler/cli/open.rb +4 -5
- data/lib/bundler/cli/outdated.rb +7 -8
- data/lib/bundler/cli/package.rb +1 -1
- data/lib/bundler/cli/platform.rb +2 -3
- data/lib/bundler/cli/show.rb +9 -9
- data/lib/bundler/cli/update.rb +2 -3
- data/lib/bundler/cli/viz.rb +1 -2
- data/lib/bundler/cli.rb +85 -74
- data/lib/bundler/constants.rb +1 -1
- data/lib/bundler/current_ruby.rb +38 -3
- data/lib/bundler/definition.rb +83 -88
- data/lib/bundler/dep_proxy.rb +11 -9
- data/lib/bundler/dependency.rb +17 -11
- data/lib/bundler/deployment.rb +2 -2
- data/lib/bundler/deprecate.rb +3 -3
- data/lib/bundler/dsl.rb +62 -43
- data/lib/bundler/env.rb +19 -12
- data/lib/bundler/environment.rb +1 -2
- data/lib/bundler/errors.rb +82 -0
- data/lib/bundler/fetcher/base.rb +20 -7
- data/lib/bundler/fetcher/dependency.rb +5 -5
- data/lib/bundler/fetcher/downloader.rb +1 -2
- data/lib/bundler/fetcher/index.rb +4 -7
- data/lib/bundler/fetcher.rb +49 -40
- data/lib/bundler/friendly_errors.rb +15 -8
- data/lib/bundler/gem_helper.rb +44 -35
- data/lib/bundler/gem_helpers.rb +7 -8
- data/lib/bundler/gem_remote_fetcher.rb +41 -0
- data/lib/bundler/gem_tasks.rb +4 -1
- data/lib/bundler/graph.rb +25 -24
- data/lib/bundler/index.rb +21 -18
- data/lib/bundler/injector.rb +2 -4
- data/lib/bundler/inline.rb +3 -3
- data/lib/bundler/installer/gem_installer.rb +76 -0
- data/lib/bundler/installer/parallel_installer.rb +22 -13
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/installer.rb +57 -144
- data/lib/bundler/lazy_specification.rb +4 -5
- data/lib/bundler/lockfile_parser.rb +21 -19
- data/lib/bundler/man/bundle +2 -2
- data/lib/bundler/man/bundle-config +2 -2
- data/lib/bundler/man/bundle-config.txt +6 -4
- data/lib/bundler/man/bundle-exec +1 -1
- data/lib/bundler/man/bundle-exec.txt +1 -1
- data/lib/bundler/man/bundle-gem +80 -0
- data/lib/bundler/man/bundle-gem.txt +90 -0
- data/lib/bundler/man/bundle-install +37 -6
- data/lib/bundler/man/bundle-install.txt +68 -44
- data/lib/bundler/man/bundle-lock +55 -0
- data/lib/bundler/man/bundle-lock.txt +60 -0
- data/lib/bundler/man/bundle-package +1 -1
- data/lib/bundler/man/bundle-package.txt +1 -1
- data/lib/bundler/man/bundle-platform +1 -1
- data/lib/bundler/man/bundle-platform.txt +1 -1
- data/lib/bundler/man/bundle-update +1 -1
- data/lib/bundler/man/bundle-update.txt +1 -1
- data/lib/bundler/man/bundle.txt +2 -2
- data/lib/bundler/man/gemfile.5 +17 -1
- data/lib/bundler/man/gemfile.5.txt +12 -1
- data/lib/bundler/match_platform.rb +4 -4
- data/lib/bundler/psyched_yaml.rb +5 -5
- data/lib/bundler/remote_specification.rb +1 -1
- data/lib/bundler/resolver.rb +93 -88
- data/lib/bundler/retry.rb +9 -10
- data/lib/bundler/ruby_dsl.rb +1 -1
- data/lib/bundler/ruby_version.rb +7 -10
- data/lib/bundler/rubygems_ext.rb +32 -27
- data/lib/bundler/{gem_installer.rb → rubygems_gem_installer.rb} +2 -2
- data/lib/bundler/rubygems_integration.rb +85 -70
- data/lib/bundler/runtime.rb +65 -61
- data/lib/bundler/settings.rb +27 -26
- data/lib/bundler/setup.rb +3 -3
- data/lib/bundler/shared_helpers.rb +45 -20
- data/lib/bundler/similarity_detector.rb +19 -21
- data/lib/bundler/source/git/git_proxy.rb +52 -26
- data/lib/bundler/source/git.rb +29 -31
- data/lib/bundler/source/path/installer.rb +4 -4
- data/lib/bundler/source/path.rb +25 -28
- data/lib/bundler/source/rubygems/remote.rb +3 -3
- data/lib/bundler/source/rubygems.rb +62 -48
- data/lib/bundler/source.rb +4 -5
- data/lib/bundler/source_list.rb +4 -4
- data/lib/bundler/spec_set.rb +17 -15
- data/lib/bundler/ssl_certs/certificate_manager.rb +5 -6
- data/lib/bundler/stub_specification.rb +2 -2
- data/lib/bundler/templates/Executable +5 -5
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +42 -6
- data/lib/bundler/templates/newgem/README.md.tt +1 -1
- data/lib/bundler/templates/newgem/Rakefile.tt +4 -2
- data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
- data/lib/bundler/ui/rg_proxy.rb +2 -2
- data/lib/bundler/ui/shell.rb +10 -6
- data/lib/bundler/ui.rb +3 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +82 -71
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +9 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +40 -21
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -0
- data/lib/bundler/vendored_molinillo.rb +1 -1
- data/lib/bundler/vendored_persistent.rb +3 -3
- data/lib/bundler/vendored_thor.rb +2 -2
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +4 -5
- data/lib/bundler.rb +99 -120
- data/man/bundle-config.ronn +4 -2
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +13 -6
- data/man/bundle-lock.ronn +47 -0
- data/man/bundle.ronn +1 -1
- data/man/gemfile.5.ronn +8 -0
- data/man/index.txt +1 -0
- metadata +36 -8
- data/bin/bundle +0 -21
- data/bin/bundler +0 -21
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
require "monitor"
|
|
2
|
+
require "rubygems"
|
|
3
|
+
require "rubygems/config_file"
|
|
4
4
|
|
|
5
5
|
module Bundler
|
|
6
6
|
class RubygemsIntegration
|
|
@@ -62,11 +62,15 @@ module Bundler
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def configuration
|
|
65
|
+
require "bundler/psyched_yaml"
|
|
65
66
|
Gem.configuration
|
|
66
67
|
rescue Gem::SystemExitException => e
|
|
67
68
|
Bundler.ui.error "#{e.class}: #{e.message}"
|
|
68
69
|
Bundler.ui.trace e
|
|
69
|
-
raise
|
|
70
|
+
raise
|
|
71
|
+
rescue YamlLibrarySyntaxError => e
|
|
72
|
+
raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
|
|
73
|
+
"usually located in ~/.gemrc, contains invalid YAML syntax.")
|
|
70
74
|
end
|
|
71
75
|
|
|
72
76
|
def ruby_engine
|
|
@@ -111,14 +115,14 @@ module Bundler
|
|
|
111
115
|
end
|
|
112
116
|
|
|
113
117
|
def gem_cache
|
|
114
|
-
gem_path.map{|p| File.expand_path("cache", p) }
|
|
118
|
+
gem_path.map {|p| File.expand_path("cache", p) }
|
|
115
119
|
end
|
|
116
120
|
|
|
117
121
|
def spec_cache_dirs
|
|
118
122
|
@spec_cache_dirs ||= begin
|
|
119
|
-
dirs = gem_path.map {|dir| File.join(dir,
|
|
123
|
+
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
|
|
120
124
|
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in Rubygems 2.0.3 or earlier
|
|
121
|
-
dirs.uniq.select {|dir| File.directory? dir}
|
|
125
|
+
dirs.uniq.select {|dir| File.directory? dir }
|
|
122
126
|
end
|
|
123
127
|
end
|
|
124
128
|
|
|
@@ -131,7 +135,7 @@ module Bundler
|
|
|
131
135
|
end
|
|
132
136
|
|
|
133
137
|
def repository_subdirectories
|
|
134
|
-
%w
|
|
138
|
+
%w(cache doc gems specifications)
|
|
135
139
|
end
|
|
136
140
|
|
|
137
141
|
def clear_paths
|
|
@@ -151,11 +155,11 @@ module Bundler
|
|
|
151
155
|
# RubyGems 2.2+ can put binary extension into dedicated folders,
|
|
152
156
|
# therefore use RubyGems facilities to obtain their load paths.
|
|
153
157
|
if Gem::Specification.method_defined? :full_require_paths
|
|
154
|
-
loaded_gem_paths = Gem.loaded_specs.map {|
|
|
158
|
+
loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
|
|
155
159
|
loaded_gem_paths.flatten
|
|
156
160
|
else
|
|
157
161
|
$LOAD_PATH.select do |p|
|
|
158
|
-
Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ }
|
|
162
|
+
Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
|
|
159
163
|
end
|
|
160
164
|
end
|
|
161
165
|
end
|
|
@@ -180,18 +184,26 @@ module Bundler
|
|
|
180
184
|
[] # if we can't download them, there aren't any
|
|
181
185
|
end
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
# TODO: This is for older versions of Rubygems... should we support the
|
|
188
|
+
# X-Gemfile-Source header on these old versions?
|
|
189
|
+
# Maybe the newer implementation will work on older Rubygems?
|
|
190
|
+
# It seems difficult to keep this implementation and still send the header.
|
|
191
|
+
def fetch_all_remote_specs(remote)
|
|
192
|
+
old_sources = Bundler.rubygems.sources
|
|
193
|
+
Bundler.rubygems.sources = [remote.uri.to_s]
|
|
184
194
|
# Fetch all specs, minus prerelease specs
|
|
185
195
|
spec_list = fetch_specs(true, false)
|
|
186
196
|
# Then fetch the prerelease specs
|
|
187
197
|
fetch_prerelease_specs.each {|k, v| spec_list[k] += v }
|
|
188
198
|
|
|
189
|
-
|
|
199
|
+
spec_list
|
|
200
|
+
ensure
|
|
201
|
+
Bundler.rubygems.sources = old_sources
|
|
190
202
|
end
|
|
191
203
|
|
|
192
204
|
def with_build_args(args)
|
|
193
205
|
ext_lock.synchronize do
|
|
194
|
-
old_args =
|
|
206
|
+
old_args = build_args
|
|
195
207
|
begin
|
|
196
208
|
self.build_args = args
|
|
197
209
|
yield
|
|
@@ -202,12 +214,12 @@ module Bundler
|
|
|
202
214
|
end
|
|
203
215
|
|
|
204
216
|
def gem_from_path(path, policy = nil)
|
|
205
|
-
require
|
|
217
|
+
require "rubygems/format"
|
|
206
218
|
Gem::Format.from_file_by_path(path, policy)
|
|
207
219
|
end
|
|
208
220
|
|
|
209
221
|
def spec_from_gem(path, policy = nil)
|
|
210
|
-
require
|
|
222
|
+
require "rubygems/security"
|
|
211
223
|
gem_from_path(path, security_policies[policy]).spec
|
|
212
224
|
rescue Gem::Package::FormatError
|
|
213
225
|
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
|
|
@@ -216,7 +228,7 @@ module Bundler
|
|
|
216
228
|
e.message =~ /unknown trust policy|unsigned gem/i ||
|
|
217
229
|
e.message =~ /couldn't verify (meta)?data signature/i
|
|
218
230
|
raise SecurityError,
|
|
219
|
-
"The gem #{File.basename(path,
|
|
231
|
+
"The gem #{File.basename(path, ".gem")} can't be installed because " \
|
|
220
232
|
"the security policy didn't allow it, with the message: #{e.message}"
|
|
221
233
|
else
|
|
222
234
|
raise e
|
|
@@ -224,12 +236,12 @@ module Bundler
|
|
|
224
236
|
end
|
|
225
237
|
|
|
226
238
|
def build(spec, skip_validation = false)
|
|
227
|
-
require
|
|
239
|
+
require "rubygems/builder"
|
|
228
240
|
Gem::Builder.new(spec).build
|
|
229
241
|
end
|
|
230
242
|
|
|
231
243
|
def build_gem(gem_dir, spec)
|
|
232
|
-
|
|
244
|
+
build(spec)
|
|
233
245
|
end
|
|
234
246
|
|
|
235
247
|
def download_gem(spec, uri, path)
|
|
@@ -239,12 +251,12 @@ module Bundler
|
|
|
239
251
|
end
|
|
240
252
|
|
|
241
253
|
def security_policy_keys
|
|
242
|
-
%w
|
|
254
|
+
%w(High Medium Low AlmostNo No).map {|level| "#{level}Security" }
|
|
243
255
|
end
|
|
244
256
|
|
|
245
257
|
def security_policies
|
|
246
258
|
@security_policies ||= begin
|
|
247
|
-
require
|
|
259
|
+
require "rubygems/security"
|
|
248
260
|
Gem::Security::Policies
|
|
249
261
|
rescue LoadError, NameError
|
|
250
262
|
{}
|
|
@@ -255,8 +267,8 @@ module Bundler
|
|
|
255
267
|
# Disable rubygems' gem activation system
|
|
256
268
|
::Kernel.class_eval do
|
|
257
269
|
if private_method_defined?(:gem_original_require)
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
alias_method :rubygems_require, :require
|
|
271
|
+
alias_method :require, :gem_original_require
|
|
260
272
|
end
|
|
261
273
|
|
|
262
274
|
undef gem
|
|
@@ -266,11 +278,11 @@ module Bundler
|
|
|
266
278
|
def replace_gem(specs)
|
|
267
279
|
reverse_rubygems_kernel_mixin
|
|
268
280
|
|
|
269
|
-
executables = specs.map
|
|
281
|
+
executables = specs.map(&:executables).flatten
|
|
270
282
|
|
|
271
283
|
::Kernel.send(:define_method, :gem) do |dep, *reqs|
|
|
272
|
-
if executables.include? File.basename(caller.first.split(
|
|
273
|
-
|
|
284
|
+
if executables.include? File.basename(caller.first.split(":").first)
|
|
285
|
+
break
|
|
274
286
|
end
|
|
275
287
|
reqs.pop if reqs.last.is_a?(Hash)
|
|
276
288
|
|
|
@@ -278,7 +290,7 @@ module Bundler
|
|
|
278
290
|
dep = Gem::Dependency.new(dep, reqs)
|
|
279
291
|
end
|
|
280
292
|
|
|
281
|
-
spec = specs.find
|
|
293
|
+
spec = specs.find {|s| s.name == dep.name }
|
|
282
294
|
|
|
283
295
|
if spec.nil?
|
|
284
296
|
|
|
@@ -330,27 +342,25 @@ module Bundler
|
|
|
330
342
|
# under bundler. The new Gem.bin_path only considers gems in
|
|
331
343
|
# +specs+
|
|
332
344
|
def replace_bin_path(specs)
|
|
333
|
-
gem_class = (class << Gem
|
|
345
|
+
gem_class = (class << Gem; self; end)
|
|
334
346
|
redefine_method(gem_class, :bin_path) do |name, *args|
|
|
335
347
|
exec_name = args.first
|
|
336
348
|
|
|
337
|
-
if exec_name ==
|
|
338
|
-
return ENV['BUNDLE_BIN_PATH']
|
|
339
|
-
end
|
|
349
|
+
return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
|
|
340
350
|
|
|
341
351
|
spec = nil
|
|
342
352
|
|
|
343
353
|
if exec_name
|
|
344
|
-
spec = specs.find {
|
|
345
|
-
|
|
354
|
+
spec = specs.find {|s| s.executables.include?(exec_name) }
|
|
355
|
+
raise(Gem::Exception, "can't find executable #{exec_name}") unless spec
|
|
346
356
|
unless spec.name == name
|
|
347
357
|
warn "Bundler is using a binstub that was created for a different gem.\n" \
|
|
348
358
|
"This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
|
|
349
359
|
"to work around a system/bundle conflict."
|
|
350
360
|
end
|
|
351
361
|
else
|
|
352
|
-
spec = specs.find
|
|
353
|
-
|
|
362
|
+
spec = specs.find {|s| s.name == name }
|
|
363
|
+
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name = spec.default_executable
|
|
354
364
|
end
|
|
355
365
|
|
|
356
366
|
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
|
@@ -362,8 +372,8 @@ module Bundler
|
|
|
362
372
|
# Because Bundler has a static view of what specs are available,
|
|
363
373
|
# we don't #refresh, so stub it out.
|
|
364
374
|
def replace_refresh
|
|
365
|
-
gem_class = (class << Gem
|
|
366
|
-
redefine_method(gem_class, :refresh) {
|
|
375
|
+
gem_class = (class << Gem; self; end)
|
|
376
|
+
redefine_method(gem_class, :refresh) {}
|
|
367
377
|
end
|
|
368
378
|
|
|
369
379
|
# Replace or hook into Rubygems to provide a bundlerized view
|
|
@@ -391,8 +401,8 @@ module Bundler
|
|
|
391
401
|
|
|
392
402
|
# This backport fixes the marshaling of @segments.
|
|
393
403
|
def backport_yaml_initialize
|
|
394
|
-
redefine_method(Gem::Version, :yaml_initialize) do |
|
|
395
|
-
@version = map[
|
|
404
|
+
redefine_method(Gem::Version, :yaml_initialize) do |_, map|
|
|
405
|
+
@version = map["version"]
|
|
396
406
|
@segments = nil
|
|
397
407
|
@hash = nil
|
|
398
408
|
end
|
|
@@ -446,7 +456,7 @@ module Bundler
|
|
|
446
456
|
|
|
447
457
|
def stub_rubygems(specs)
|
|
448
458
|
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
|
|
449
|
-
source_index_class = (class << Gem::SourceIndex
|
|
459
|
+
source_index_class = (class << Gem::SourceIndex; self; end)
|
|
450
460
|
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
|
451
461
|
source_index = Gem::SourceIndex.new
|
|
452
462
|
source_index.spec_dirs = *args
|
|
@@ -499,9 +509,9 @@ module Bundler
|
|
|
499
509
|
def stub_rubygems(specs)
|
|
500
510
|
Gem::Specification.all = specs
|
|
501
511
|
|
|
502
|
-
Gem.post_reset
|
|
512
|
+
Gem.post_reset do
|
|
503
513
|
Gem::Specification.all = specs
|
|
504
|
-
|
|
514
|
+
end
|
|
505
515
|
|
|
506
516
|
stub_source_index(specs)
|
|
507
517
|
end
|
|
@@ -521,7 +531,8 @@ module Bundler
|
|
|
521
531
|
# you call Gem::Installer#install with an :install_dir set. We have to
|
|
522
532
|
# change it back for our sudo mode to work.
|
|
523
533
|
def preserve_paths
|
|
524
|
-
old_dir
|
|
534
|
+
old_dir = gem_dir
|
|
535
|
+
old_path = gem_path
|
|
525
536
|
yield
|
|
526
537
|
Gem.use_paths(old_dir, old_path)
|
|
527
538
|
end
|
|
@@ -532,7 +543,7 @@ module Bundler
|
|
|
532
543
|
# Rubygems 1.8.20 and adds the skip_validation parameter, so that's
|
|
533
544
|
# when we start passing it through.
|
|
534
545
|
def build(spec, skip_validation = false)
|
|
535
|
-
require
|
|
546
|
+
require "rubygems/builder"
|
|
536
547
|
Gem::Builder.new(spec).build(skip_validation)
|
|
537
548
|
end
|
|
538
549
|
end
|
|
@@ -555,48 +566,55 @@ module Bundler
|
|
|
555
566
|
Gem::Specification.find_all_by_name name
|
|
556
567
|
end
|
|
557
568
|
|
|
558
|
-
def fetch_specs(source, name)
|
|
569
|
+
def fetch_specs(source, remote, name)
|
|
559
570
|
path = source + "#{name}.#{Gem.marshal_version}.gz"
|
|
560
|
-
|
|
571
|
+
fetcher = gem_remote_fetcher
|
|
572
|
+
fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
|
|
573
|
+
string = fetcher.fetch_path(path)
|
|
561
574
|
Bundler.load_marshal(string)
|
|
562
575
|
rescue Gem::RemoteFetcher::FetchError => e
|
|
563
576
|
# it's okay for prerelease to fail
|
|
564
577
|
raise e unless name == "prerelease_specs"
|
|
565
578
|
end
|
|
566
579
|
|
|
567
|
-
def fetch_all_remote_specs
|
|
580
|
+
def fetch_all_remote_specs(remote)
|
|
568
581
|
# Since SpecFetcher now returns NameTuples, we just fetch directly
|
|
569
582
|
# and unmarshal the array ourselves.
|
|
570
583
|
hash = {}
|
|
571
584
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
585
|
+
source = remote.uri
|
|
586
|
+
source = URI.parse(source.to_s) unless source.is_a?(URI)
|
|
587
|
+
hash[source] = fetch_specs(source, remote, "specs")
|
|
575
588
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
end
|
|
589
|
+
pres = fetch_specs(source, remote, "prerelease_specs")
|
|
590
|
+
hash[source].push(*pres) if pres && !pres.empty?
|
|
579
591
|
|
|
580
592
|
hash
|
|
581
593
|
end
|
|
582
594
|
|
|
583
595
|
def download_gem(spec, uri, path)
|
|
584
|
-
require 'resolv'
|
|
585
596
|
uri = Bundler.settings.mirror_for(uri)
|
|
586
|
-
|
|
587
|
-
fetcher =
|
|
597
|
+
fetcher = gem_remote_fetcher
|
|
598
|
+
fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
|
|
588
599
|
fetcher.download(spec, uri, path)
|
|
589
600
|
end
|
|
590
601
|
|
|
602
|
+
def gem_remote_fetcher
|
|
603
|
+
require "resolv"
|
|
604
|
+
proxy = configuration[:http_proxy]
|
|
605
|
+
dns = Resolv::DNS.new
|
|
606
|
+
Bundler::GemRemoteFetcher.new(proxy, dns)
|
|
607
|
+
end
|
|
608
|
+
|
|
591
609
|
def gem_from_path(path, policy = nil)
|
|
592
|
-
require
|
|
610
|
+
require "rubygems/package"
|
|
593
611
|
p = Gem::Package.new(path)
|
|
594
612
|
p.security_policy = policy if policy
|
|
595
|
-
|
|
613
|
+
p
|
|
596
614
|
end
|
|
597
615
|
|
|
598
616
|
def build(spec, skip_validation = false)
|
|
599
|
-
require
|
|
617
|
+
require "rubygems/package"
|
|
600
618
|
Gem::Package.build(spec, skip_validation)
|
|
601
619
|
end
|
|
602
620
|
|
|
@@ -613,23 +631,21 @@ module Bundler
|
|
|
613
631
|
end
|
|
614
632
|
|
|
615
633
|
def all_specs
|
|
616
|
-
require
|
|
634
|
+
require "bundler/remote_specification"
|
|
617
635
|
Gem::Specification.stubs.map do |stub|
|
|
618
636
|
StubSpecification.from_stub(stub)
|
|
619
637
|
end
|
|
620
638
|
end
|
|
621
639
|
|
|
622
640
|
def backport_ext_builder_monitor
|
|
623
|
-
require
|
|
641
|
+
require "rubygems/ext"
|
|
624
642
|
|
|
625
643
|
Gem::Ext::Builder.class_eval do
|
|
626
|
-
|
|
644
|
+
unless const_defined?(:CHDIR_MONITOR)
|
|
627
645
|
const_set(:CHDIR_MONITOR, EXT_LOCK)
|
|
628
646
|
end
|
|
629
647
|
|
|
630
|
-
if const_defined?(:CHDIR_MUTEX)
|
|
631
|
-
remove_const(:CHDIR_MUTEX)
|
|
632
|
-
end
|
|
648
|
+
remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
|
|
633
649
|
const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
|
|
634
650
|
end
|
|
635
651
|
end
|
|
@@ -646,22 +662,21 @@ module Bundler
|
|
|
646
662
|
end
|
|
647
663
|
end
|
|
648
664
|
end
|
|
649
|
-
|
|
650
665
|
end
|
|
651
666
|
|
|
652
667
|
if RubygemsIntegration.provides?(">= 2.1.0")
|
|
653
668
|
@rubygems = RubygemsIntegration::MoreFuture.new
|
|
654
669
|
elsif RubygemsIntegration.provides?(">= 1.99.99")
|
|
655
670
|
@rubygems = RubygemsIntegration::Future.new
|
|
656
|
-
elsif RubygemsIntegration.provides?(
|
|
671
|
+
elsif RubygemsIntegration.provides?(">= 1.8.20")
|
|
657
672
|
@rubygems = RubygemsIntegration::MoreModern.new
|
|
658
|
-
elsif RubygemsIntegration.provides?(
|
|
673
|
+
elsif RubygemsIntegration.provides?(">= 1.8.5")
|
|
659
674
|
@rubygems = RubygemsIntegration::Modern.new
|
|
660
|
-
elsif RubygemsIntegration.provides?(
|
|
675
|
+
elsif RubygemsIntegration.provides?(">= 1.8.0")
|
|
661
676
|
@rubygems = RubygemsIntegration::AlmostModern.new
|
|
662
|
-
elsif RubygemsIntegration.provides?(
|
|
677
|
+
elsif RubygemsIntegration.provides?(">= 1.7.0")
|
|
663
678
|
@rubygems = RubygemsIntegration::Transitional.new
|
|
664
|
-
elsif RubygemsIntegration.provides?(
|
|
679
|
+
elsif RubygemsIntegration.provides?(">= 1.4.0")
|
|
665
680
|
@rubygems = RubygemsIntegration::Legacy.new
|
|
666
681
|
else # Rubygems 1.3.6 and 1.3.7
|
|
667
682
|
@rubygems = RubygemsIntegration::Ancient.new
|
data/lib/bundler/runtime.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Bundler
|
|
|
5
5
|
include SharedHelpers
|
|
6
6
|
|
|
7
7
|
def setup(*groups)
|
|
8
|
-
groups.map!
|
|
8
|
+
groups.map!(&:to_sym)
|
|
9
9
|
|
|
10
10
|
# Has to happen first
|
|
11
11
|
clean_load_path
|
|
@@ -21,7 +21,7 @@ module Bundler
|
|
|
21
21
|
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
if activated_spec = Bundler.rubygems.loaded_specs(spec.name)
|
|
24
|
+
if (activated_spec = Bundler.rubygems.loaded_specs(spec.name)) && activated_spec.version != spec.version
|
|
25
25
|
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
|
26
26
|
"but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
|
|
27
27
|
"`bundle exec` to your command may solve this."
|
|
@@ -35,7 +35,7 @@ module Bundler
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
Bundler.rubygems.mark_loaded(spec)
|
|
38
|
-
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
|
38
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
|
|
39
39
|
$LOAD_PATH.unshift(*load_paths)
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -55,13 +55,13 @@ module Bundler
|
|
|
55
55
|
]
|
|
56
56
|
|
|
57
57
|
def require(*groups)
|
|
58
|
-
groups.map!
|
|
58
|
+
groups.map!(&:to_sym)
|
|
59
59
|
groups = [:default] if groups.empty?
|
|
60
60
|
|
|
61
61
|
@definition.dependencies.each do |dep|
|
|
62
62
|
# Skip the dependency if it is not in any of the requested
|
|
63
63
|
# groups
|
|
64
|
-
next unless (
|
|
64
|
+
next unless (dep.groups & groups).any? && dep.current_platform?
|
|
65
65
|
|
|
66
66
|
required_file = nil
|
|
67
67
|
|
|
@@ -73,18 +73,24 @@ module Bundler
|
|
|
73
73
|
# Allow `require: true` as an alias for `require: <name>`
|
|
74
74
|
file = dep.name if file == true
|
|
75
75
|
required_file = file
|
|
76
|
-
|
|
76
|
+
begin
|
|
77
|
+
Kernel.require file
|
|
78
|
+
rescue => e
|
|
79
|
+
raise e if e.is_a?(LoadError) # we handle this a little later
|
|
80
|
+
raise Bundler::GemRequireError.new e,
|
|
81
|
+
"There was an error while trying to load the gem '#{file}'."
|
|
82
|
+
end
|
|
77
83
|
end
|
|
78
84
|
rescue LoadError => e
|
|
79
|
-
REQUIRE_ERRORS.find {
|
|
85
|
+
REQUIRE_ERRORS.find {|r| r =~ e.message }
|
|
80
86
|
raise if dep.autorequire || $1 != required_file
|
|
81
87
|
|
|
82
|
-
if dep.autorequire.nil? && dep.name.include?(
|
|
88
|
+
if dep.autorequire.nil? && dep.name.include?("-")
|
|
83
89
|
begin
|
|
84
|
-
namespaced_file = dep.name.
|
|
90
|
+
namespaced_file = dep.name.tr("-", "/")
|
|
85
91
|
Kernel.require namespaced_file
|
|
86
92
|
rescue LoadError => e
|
|
87
|
-
REQUIRE_ERRORS.find {
|
|
93
|
+
REQUIRE_ERRORS.find {|r| r =~ e.message }
|
|
88
94
|
raise if $1 != namespaced_file
|
|
89
95
|
end
|
|
90
96
|
end
|
|
@@ -96,19 +102,29 @@ module Bundler
|
|
|
96
102
|
if groups.empty?
|
|
97
103
|
dependencies
|
|
98
104
|
else
|
|
99
|
-
dependencies.select {
|
|
105
|
+
dependencies.select {|d| (groups & d.groups).any? }
|
|
100
106
|
end
|
|
101
107
|
end
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
alias_method :gems, :specs
|
|
104
110
|
|
|
105
111
|
def cache(custom_path = nil)
|
|
106
112
|
cache_path = Bundler.app_cache(custom_path)
|
|
107
|
-
|
|
113
|
+
SharedHelpers.filesystem_access(cache_path) do |p|
|
|
114
|
+
FileUtils.mkdir_p(p)
|
|
115
|
+
end unless File.exist?(cache_path)
|
|
108
116
|
|
|
109
117
|
Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
|
|
118
|
+
|
|
119
|
+
# Do not try to cache specification for the gem described by the .gemspec
|
|
120
|
+
root_gem_name = nil
|
|
121
|
+
if gemspec_cache_hash = Bundler.instance_variable_get(:@gemspec_cache)
|
|
122
|
+
gemspec = gemspec_cache_hash.values.first
|
|
123
|
+
root_gem_name = gemspec.name unless gemspec.nil?
|
|
124
|
+
end
|
|
110
125
|
specs.each do |spec|
|
|
111
|
-
next if spec.name ==
|
|
126
|
+
next if spec.name == "bundler"
|
|
127
|
+
next if File.exist?("#{root_gem_name}.gemspec") && spec.source.class == Bundler::Source::Path && root_gem_name && spec.name == root_gem_name
|
|
112
128
|
spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
|
|
113
129
|
spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
|
|
114
130
|
end
|
|
@@ -122,7 +138,9 @@ module Bundler
|
|
|
122
138
|
end
|
|
123
139
|
|
|
124
140
|
def prune_cache(cache_path)
|
|
125
|
-
|
|
141
|
+
SharedHelpers.filesystem_access(cache_path) do |p|
|
|
142
|
+
FileUtils.mkdir_p(p)
|
|
143
|
+
end unless File.exist?(cache_path)
|
|
126
144
|
resolve = @definition.resolve
|
|
127
145
|
prune_gem_cache(resolve, cache_path)
|
|
128
146
|
prune_git_and_path_cache(resolve, cache_path)
|
|
@@ -159,51 +177,20 @@ module Bundler
|
|
|
159
177
|
spec_gem_executables.flatten!
|
|
160
178
|
|
|
161
179
|
stale_gem_bins = gem_bins - spec_gem_executables
|
|
162
|
-
stale_git_dirs = git_dirs - spec_git_paths
|
|
180
|
+
stale_git_dirs = git_dirs - spec_git_paths - ["#{Gem.dir}/bundler/gems/extensions"]
|
|
163
181
|
stale_git_cache_dirs = git_cache_dirs - spec_git_cache_dirs
|
|
164
182
|
stale_gem_dirs = gem_dirs - spec_gem_paths
|
|
165
183
|
stale_gem_files = gem_files - spec_cache_paths
|
|
166
184
|
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
|
167
185
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
parts = full_name.split('-')
|
|
172
|
-
name = parts[0..-2].join('-')
|
|
173
|
-
version = parts.last
|
|
174
|
-
output = "#{name} (#{version})"
|
|
175
|
-
|
|
176
|
-
if dry_run
|
|
177
|
-
Bundler.ui.info "Would have removed #{output}"
|
|
178
|
-
else
|
|
179
|
-
Bundler.ui.info "Removing #{output}"
|
|
180
|
-
FileUtils.rm_rf(gem_dir)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
output
|
|
184
|
-
end + stale_git_dirs.collect do |gem_dir|
|
|
185
|
-
full_name = Pathname.new(gem_dir).basename.to_s
|
|
186
|
-
|
|
187
|
-
parts = full_name.split('-')
|
|
188
|
-
name = parts[0..-2].join('-')
|
|
189
|
-
revision = parts[-1]
|
|
190
|
-
output = "#{name} (#{revision})"
|
|
191
|
-
|
|
192
|
-
if dry_run
|
|
193
|
-
Bundler.ui.info "Would have removed #{output}"
|
|
194
|
-
else
|
|
195
|
-
Bundler.ui.info "Removing #{output}"
|
|
196
|
-
FileUtils.rm_rf(gem_dir)
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
output
|
|
200
|
-
end
|
|
186
|
+
removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
|
187
|
+
removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
|
188
|
+
output = removed_stale_gem_dirs + removed_stale_git_dirs
|
|
201
189
|
|
|
202
190
|
unless dry_run
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
stale_git_cache_dirs.each { |dir| FileUtils.rm_rf(dir) if File.exist?(dir) }
|
|
191
|
+
stale_files = stale_gem_bins + stale_gem_files + stale_gemspec_files
|
|
192
|
+
stale_files.each {|file| FileUtils.rm(file) if File.exist?(file) }
|
|
193
|
+
stale_git_cache_dirs.each {|dir| FileUtils.rm_rf(dir) if File.exist?(dir) }
|
|
207
194
|
end
|
|
208
195
|
|
|
209
196
|
output
|
|
@@ -213,7 +200,7 @@ module Bundler
|
|
|
213
200
|
begin
|
|
214
201
|
ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
|
215
202
|
rescue Gem::GemNotFoundException
|
|
216
|
-
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../
|
|
203
|
+
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__)
|
|
217
204
|
end
|
|
218
205
|
|
|
219
206
|
# Set BUNDLE_GEMFILE
|
|
@@ -225,7 +212,7 @@ module Bundler
|
|
|
225
212
|
private
|
|
226
213
|
|
|
227
214
|
def prune_gem_cache(resolve, cache_path)
|
|
228
|
-
cached
|
|
215
|
+
cached = Dir["#{cache_path}/*.gem"]
|
|
229
216
|
|
|
230
217
|
cached = cached.delete_if do |path|
|
|
231
218
|
spec = Bundler.rubygems.spec_from_gem path
|
|
@@ -246,7 +233,7 @@ module Bundler
|
|
|
246
233
|
end
|
|
247
234
|
|
|
248
235
|
def prune_git_and_path_cache(resolve, cache_path)
|
|
249
|
-
cached
|
|
236
|
+
cached = Dir["#{cache_path}/*/.bundlecache"]
|
|
250
237
|
|
|
251
238
|
cached = cached.delete_if do |path|
|
|
252
239
|
name = File.basename(File.dirname(path))
|
|
@@ -270,20 +257,37 @@ module Bundler
|
|
|
270
257
|
|
|
271
258
|
def setup_manpath
|
|
272
259
|
# Store original MANPATH for restoration later in with_clean_env()
|
|
273
|
-
ENV[
|
|
260
|
+
ENV["BUNDLE_ORIG_MANPATH"] = ENV["MANPATH"]
|
|
274
261
|
|
|
275
262
|
# Add man/ subdirectories from activated bundles to MANPATH for man(1)
|
|
276
263
|
manuals = $LOAD_PATH.map do |path|
|
|
277
|
-
man_subdir = path.sub(/lib$/,
|
|
278
|
-
man_subdir unless Dir[man_subdir +
|
|
264
|
+
man_subdir = path.sub(/lib$/, "man")
|
|
265
|
+
man_subdir unless Dir[man_subdir + "/man?/"].empty?
|
|
279
266
|
end.compact
|
|
280
267
|
|
|
281
268
|
unless manuals.empty?
|
|
282
|
-
ENV[
|
|
283
|
-
ENV[
|
|
269
|
+
ENV["MANPATH"] = manuals.concat(
|
|
270
|
+
ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
|
|
284
271
|
).uniq.join(File::PATH_SEPARATOR)
|
|
285
272
|
end
|
|
286
273
|
end
|
|
287
274
|
|
|
275
|
+
def remove_dir(dir, dry_run)
|
|
276
|
+
full_name = Pathname.new(dir).basename.to_s
|
|
277
|
+
|
|
278
|
+
parts = full_name.split("-")
|
|
279
|
+
name = parts[0..-2].join("-")
|
|
280
|
+
version = parts.last
|
|
281
|
+
output = "#{name} (#{version})"
|
|
282
|
+
|
|
283
|
+
if dry_run
|
|
284
|
+
Bundler.ui.info "Would have removed #{output}"
|
|
285
|
+
else
|
|
286
|
+
Bundler.ui.info "Removing #{output}"
|
|
287
|
+
FileUtils.rm_rf(dir)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
output
|
|
291
|
+
end
|
|
288
292
|
end
|
|
289
293
|
end
|