bundler 1.0.22 → 1.1.pre
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.
- data/CHANGELOG.md +15 -181
- data/ISSUES.md +11 -26
- data/LICENSE +0 -2
- data/Rakefile +67 -116
- data/UPGRADING.md +4 -4
- data/bin/bundle +10 -10
- data/bundler.gemspec +5 -5
- data/lib/bundler.rb +15 -25
- data/lib/bundler/capistrano.rb +2 -2
- data/lib/bundler/cli.rb +41 -72
- data/lib/bundler/definition.rb +11 -37
- data/lib/bundler/dependency.rb +9 -13
- data/lib/bundler/deployment.rb +3 -8
- data/lib/bundler/dsl.rb +10 -24
- data/lib/bundler/fetcher.rb +101 -0
- data/lib/bundler/gem_helper.rb +6 -11
- data/lib/bundler/index.rb +8 -15
- data/lib/bundler/installer.rb +55 -35
- data/lib/bundler/lazy_specification.rb +7 -10
- data/lib/bundler/remote_specification.rb +6 -8
- data/lib/bundler/resolver.rb +18 -12
- data/lib/bundler/rubygems_ext.rb +3 -20
- data/lib/bundler/runtime.rb +57 -8
- data/lib/bundler/settings.rb +6 -4
- data/lib/bundler/setup.rb +5 -12
- data/lib/bundler/shared_helpers.rb +100 -4
- data/lib/bundler/source.rb +61 -106
- data/lib/bundler/spec_set.rb +8 -9
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +0 -2
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +3 -6
- data/lib/bundler/ui.rb +1 -4
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +464 -0
- data/lib/bundler/vendor/thor.rb +4 -43
- data/lib/bundler/vendor/thor/actions.rb +11 -28
- data/lib/bundler/vendor/thor/actions/create_file.rb +2 -2
- data/lib/bundler/vendor/thor/actions/directory.rb +2 -2
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +0 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +15 -56
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +10 -15
- data/lib/bundler/vendor/thor/base.rb +4 -24
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +0 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +0 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +0 -0
- data/lib/bundler/vendor/thor/error.rb +0 -0
- data/lib/bundler/vendor/thor/invocation.rb +0 -0
- data/lib/bundler/vendor/thor/parser.rb +0 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +0 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +2 -2
- data/lib/bundler/vendor/thor/parser/option.rb +1 -1
- data/lib/bundler/vendor/thor/parser/options.rb +16 -17
- data/lib/bundler/vendor/thor/shell.rb +0 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +13 -40
- data/lib/bundler/vendor/thor/shell/color.rb +0 -0
- data/lib/bundler/vendor/thor/task.rb +4 -3
- data/lib/bundler/vendor/thor/util.rb +2 -2
- data/lib/bundler/vendor/thor/version.rb +1 -1
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +0 -2
- data/man/bundle-install.ronn +3 -6
- data/man/gemfile.5.ronn +2 -7
- data/spec/cache/gems_spec.rb +0 -11
- data/spec/cache/git_spec.rb +2 -5
- data/spec/install/deploy_spec.rb +8 -8
- data/spec/install/gems/dependency_api_spec.rb +85 -0
- data/spec/install/gems/flex_spec.rb +4 -4
- data/spec/install/gems/groups_spec.rb +3 -17
- data/spec/install/gems/platform_spec.rb +16 -0
- data/spec/install/gems/simple_case_spec.rb +24 -88
- data/spec/install/gems/standalone_spec.rb +162 -0
- data/spec/install/gems/sudo_spec.rb +2 -3
- data/spec/install/gemspec_spec.rb +0 -38
- data/spec/install/git_spec.rb +4 -3
- data/spec/install/invalid_spec.rb +0 -18
- data/spec/install/path_spec.rb +1 -53
- data/spec/lock/git_spec.rb +1 -1
- data/spec/lock/lockfile_spec.rb +16 -72
- data/spec/other/check_spec.rb +6 -6
- data/spec/other/clean_spec.rb +202 -0
- data/spec/other/exec_spec.rb +7 -14
- data/spec/other/ext_spec.rb +0 -21
- data/spec/{bundler → other}/gem_helper_spec.rb +1 -16
- data/spec/other/help_spec.rb +1 -2
- data/spec/other/init_spec.rb +3 -3
- data/spec/other/newgem_spec.rb +1 -23
- data/spec/pack/gems_spec.rb +22 -0
- data/spec/quality_spec.rb +2 -6
- data/spec/runtime/require_spec.rb +10 -10
- data/spec/runtime/setup_spec.rb +12 -54
- data/spec/spec_helper.rb +7 -14
- data/spec/support/artifice/endpoint.rb +50 -0
- data/spec/support/artifice/endpoint_fallback.rb +22 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +11 -0
- data/spec/support/builders.rb +2 -25
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +12 -5
- data/spec/support/matchers.rb +16 -4
- data/spec/support/path.rb +2 -0
- data/spec/support/rubygems_ext.rb +2 -6
- data/spec/update/gems_spec.rb +2 -3
- data/spec/update/git_spec.rb +2 -2
- metadata +41 -24
- data/.travis.yml +0 -31
- data/lib/bundler/gem_installer.rb +0 -9
- data/lib/bundler/gem_tasks.rb +0 -2
- data/lib/bundler/rubygems_integration.rb +0 -344
- data/lib/bundler/vendor/thor/actions/create_link.rb +0 -57
- data/lib/bundler/vendor/thor/group.rb +0 -273
- data/lib/bundler/vendor/thor/rake_compat.rb +0 -66
- data/lib/bundler/vendor/thor/runner.rb +0 -309
- data/lib/bundler/vendored_thor.rb +0 -7
@@ -36,7 +36,7 @@ module Bundler
|
|
36
36
|
out = " #{name} (#{version}-#{platform})\n"
|
37
37
|
end
|
38
38
|
|
39
|
-
dependencies.sort_by {|d| d.
|
39
|
+
dependencies.sort_by {|d| d.name }.each do |dep|
|
40
40
|
next if dep.type == :development
|
41
41
|
out << " #{dep.to_lock}\n"
|
42
42
|
end
|
@@ -58,16 +58,13 @@ module Bundler
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def to_ary
|
62
|
-
nil
|
63
|
-
end
|
64
|
-
|
65
61
|
def method_missing(method, *args, &blk)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
62
|
+
if Gem::Specification.new.respond_to?(method)
|
63
|
+
raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
|
64
|
+
@specification.send(method, *args, &blk)
|
65
|
+
else
|
66
|
+
super
|
67
|
+
end
|
71
68
|
end
|
72
69
|
|
73
70
|
end
|
@@ -12,11 +12,11 @@ module Bundler
|
|
12
12
|
attr_reader :name, :version, :platform
|
13
13
|
attr_accessor :source
|
14
14
|
|
15
|
-
def initialize(name, version, platform,
|
16
|
-
@name
|
17
|
-
@version
|
18
|
-
@platform
|
19
|
-
@
|
15
|
+
def initialize(name, version, platform, spec_fetcher)
|
16
|
+
@name = name
|
17
|
+
@version = version
|
18
|
+
@platform = platform
|
19
|
+
@spec_fetcher = spec_fetcher
|
20
20
|
end
|
21
21
|
|
22
22
|
# Needed before installs, since the arch matters then and quick
|
@@ -43,9 +43,7 @@ module Bundler
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def _remote_specification
|
46
|
-
@specification ||=
|
47
|
-
Gem::SpecFetcher.new.fetch_spec([@name, @version, @platform], URI(@source_uri.to_s))
|
48
|
-
end
|
46
|
+
@specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform])
|
49
47
|
end
|
50
48
|
|
51
49
|
def method_missing(method, *args, &blk)
|
data/lib/bundler/resolver.rb
CHANGED
@@ -145,7 +145,7 @@ module Bundler
|
|
145
145
|
def debug
|
146
146
|
if ENV['DEBUG_RESOLVER']
|
147
147
|
debug_info = yield
|
148
|
-
debug_info = debug_info.
|
148
|
+
debug_info = debug_info.inpsect unless debug_info.is_a?(String)
|
149
149
|
$stderr.puts debug_info
|
150
150
|
end
|
151
151
|
end
|
@@ -179,15 +179,15 @@ module Bundler
|
|
179
179
|
activated[a.name] ? 0 : gems_size(a) ]
|
180
180
|
end
|
181
181
|
|
182
|
-
debug { "Activated:\n" + activated.values.map {|a| " #{a}" }.join("\n") }
|
183
|
-
debug { "Requirements:\n" + reqs.map {|r| " #{r}"}.join("\n") }
|
182
|
+
debug { "Activated:\n" + activated.values.map { |a| " #{a.name} (#{a.version})" }.join("\n") }
|
183
|
+
debug { "Requirements:\n" + reqs.map { |r| " #{r.name} (#{r.requirement})"}.join("\n") }
|
184
184
|
|
185
185
|
activated = activated.dup
|
186
186
|
|
187
187
|
# Pull off the first requirement so that we can resolve it
|
188
188
|
current = reqs.shift
|
189
189
|
|
190
|
-
debug { "Attempting:\n #{current}"}
|
190
|
+
debug { "Attempting:\n #{current.name} (#{current.requirement})"}
|
191
191
|
|
192
192
|
# Check if the gem has already been activated, if it has, we will make sure
|
193
193
|
# that the currently activated gem satisfies the requirement.
|
@@ -279,6 +279,14 @@ module Bundler
|
|
279
279
|
end
|
280
280
|
raise GemNotFound, message
|
281
281
|
else
|
282
|
+
if @missing_gems[current] >= 5
|
283
|
+
message = "Bundler could not find find gem #{current.required_by.last},"
|
284
|
+
message << "which is required by gem #{current}."
|
285
|
+
raise GemNotFound, message
|
286
|
+
end
|
287
|
+
@missing_gems[current] += 1
|
288
|
+
|
289
|
+
debug { " Could not find #{current} by #{current.required_by.last}" }
|
282
290
|
@errors[current.name] = [nil, current]
|
283
291
|
end
|
284
292
|
end
|
@@ -348,8 +356,7 @@ module Bundler
|
|
348
356
|
|
349
357
|
def search(dep)
|
350
358
|
if base = @base[dep.name] and base.any?
|
351
|
-
|
352
|
-
d = Gem::Dependency.new(base.first.name, *reqs)
|
359
|
+
d = Gem::Dependency.new(base.first.name, *[dep.requirement.as_list, base.first.version].flatten)
|
353
360
|
else
|
354
361
|
d = dep.dep
|
355
362
|
end
|
@@ -413,7 +420,7 @@ module Bundler
|
|
413
420
|
# If the origin is "bundler", the conflict is us
|
414
421
|
if origin.name == "bundler"
|
415
422
|
o << " Current Bundler version:\n"
|
416
|
-
|
423
|
+
newer_bundler_required = requirement.requirement > Gem::Requirement.new(origin.version)
|
417
424
|
# If the origin is a LockfileParser, it does not respond_to :required_by
|
418
425
|
elsif !origin.respond_to?(:required_by) || !(origin.required_by.first)
|
419
426
|
o << " In snapshot (Gemfile.lock):\n"
|
@@ -422,9 +429,9 @@ module Bundler
|
|
422
429
|
o << gem_message(origin)
|
423
430
|
|
424
431
|
# If the bundle wants a newer bundler than the running bundler, explain
|
425
|
-
if origin.name == "bundler" &&
|
426
|
-
o << "
|
427
|
-
o << "Perhaps you need to update Bundler by running `gem install bundler
|
432
|
+
if origin.name == "bundler" && newer_bundler_required
|
433
|
+
o << "Your version of Bundler is older than the one requested by the Gemfile.\n"
|
434
|
+
o << "Perhaps you need to update Bundler by running `gem install bundler`."
|
428
435
|
end
|
429
436
|
|
430
437
|
# origin is nil if the required gem and version cannot be found in any of
|
@@ -449,8 +456,7 @@ module Bundler
|
|
449
456
|
# the rest of the time, the gem cannot be found because it does not exist in the known sources
|
450
457
|
else
|
451
458
|
if requirement.required_by.first
|
452
|
-
o << "Could not find gem '#{clean_req(requirement)}',
|
453
|
-
o << "gem '#{clean_req(requirement.required_by.first)}', in any of the sources."
|
459
|
+
o << "Could not find gem '#{clean_req(requirement)}', required by '#{clean_req(requirement.required_by.first)}', in any of the sources\n"
|
454
460
|
else
|
455
461
|
o << "Could not find gem '#{clean_req(requirement)} in any of the sources\n"
|
456
462
|
end
|
data/lib/bundler/rubygems_ext.rb
CHANGED
@@ -19,7 +19,7 @@ module Gem
|
|
19
19
|
|
20
20
|
def full_gem_path
|
21
21
|
source.respond_to?(:path) ?
|
22
|
-
Pathname.new(loaded_from).dirname.expand_path
|
22
|
+
Pathname.new(loaded_from).dirname.expand_path.to_s :
|
23
23
|
rg_full_gem_path
|
24
24
|
end
|
25
25
|
|
@@ -39,12 +39,6 @@ module Gem
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# RubyGems 1.8+ used only.
|
43
|
-
remove_method :gem_dir if method_defined? :gem_dir
|
44
|
-
def gem_dir
|
45
|
-
full_gem_path
|
46
|
-
end
|
47
|
-
|
48
42
|
def groups
|
49
43
|
@groups ||= []
|
50
44
|
end
|
@@ -111,12 +105,6 @@ module Gem
|
|
111
105
|
|
112
106
|
alias eql? ==
|
113
107
|
|
114
|
-
def encode_with(coder)
|
115
|
-
to_yaml_properties.each do |ivar|
|
116
|
-
coder[ivar.to_s.sub(/^@/, '')] = instance_variable_get(ivar)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
108
|
def to_yaml_properties
|
121
109
|
instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) }
|
122
110
|
end
|
@@ -124,13 +112,11 @@ module Gem
|
|
124
112
|
def to_lock
|
125
113
|
out = " #{name}"
|
126
114
|
unless requirement == Gem::Requirement.default
|
127
|
-
|
128
|
-
out << " (#{reqs.join(', ')})"
|
115
|
+
out << " (#{requirement.to_s})"
|
129
116
|
end
|
130
117
|
out
|
131
118
|
end
|
132
119
|
|
133
|
-
# Backport of performance enhancement added to Rubygems 1.4
|
134
120
|
def matches_spec?(spec)
|
135
121
|
# name can be a Regexp, so use ===
|
136
122
|
return false unless name === spec.name
|
@@ -141,7 +127,6 @@ module Gem
|
|
141
127
|
end
|
142
128
|
|
143
129
|
class Requirement
|
144
|
-
# Backport of performance enhancement added to Rubygems 1.4
|
145
130
|
def none?
|
146
131
|
@none ||= (to_s == ">= 0")
|
147
132
|
end unless allocate.respond_to?(:none?)
|
@@ -152,14 +137,12 @@ module Gem
|
|
152
137
|
MSWIN = Gem::Platform.new('mswin32')
|
153
138
|
MINGW = Gem::Platform.new('x86-mingw32')
|
154
139
|
|
155
|
-
undef_method :hash if method_defined? :hash
|
156
140
|
def hash
|
157
141
|
@cpu.hash ^ @os.hash ^ @version.hash
|
158
142
|
end
|
159
143
|
|
160
144
|
alias eql? ==
|
161
145
|
end
|
162
|
-
|
163
146
|
end
|
164
147
|
|
165
148
|
module Bundler
|
@@ -186,7 +169,7 @@ module Bundler
|
|
186
169
|
end
|
187
170
|
|
188
171
|
def to_s
|
189
|
-
|
172
|
+
@dep.to_s
|
190
173
|
end
|
191
174
|
|
192
175
|
private
|
data/lib/bundler/runtime.rb
CHANGED
@@ -11,7 +11,7 @@ module Bundler
|
|
11
11
|
specs = groups.any? ? @definition.specs_for(groups) : requested_specs
|
12
12
|
|
13
13
|
setup_environment
|
14
|
-
|
14
|
+
cripple_rubygems(specs)
|
15
15
|
|
16
16
|
# Activate the specs
|
17
17
|
specs.each do |spec|
|
@@ -19,9 +19,9 @@ module Bundler
|
|
19
19
|
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
20
20
|
end
|
21
21
|
|
22
|
-
if activated_spec =
|
22
|
+
if activated_spec = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version
|
23
23
|
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
24
|
-
"but your Gemfile requires #{spec.name} #{spec.version}.
|
24
|
+
"but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
|
25
25
|
e.name = spec.name
|
26
26
|
if e.respond_to?(:requirement=)
|
27
27
|
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
@@ -31,7 +31,7 @@ module Bundler
|
|
31
31
|
raise e
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
Gem.loaded_specs[spec.name] = spec
|
35
35
|
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
36
36
|
$LOAD_PATH.unshift(*load_paths)
|
37
37
|
end
|
@@ -85,7 +85,7 @@ module Bundler
|
|
85
85
|
alias gems specs
|
86
86
|
|
87
87
|
def cache
|
88
|
-
FileUtils.mkdir_p(cache_path)
|
88
|
+
FileUtils.mkdir_p(cache_path)
|
89
89
|
|
90
90
|
Bundler.ui.info "Updating .gem files in vendor/cache"
|
91
91
|
specs.each do |spec|
|
@@ -96,13 +96,13 @@ module Bundler
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def prune_cache
|
99
|
-
FileUtils.mkdir_p(cache_path)
|
99
|
+
FileUtils.mkdir_p(cache_path)
|
100
100
|
|
101
101
|
resolve = @definition.resolve
|
102
102
|
cached = Dir["#{cache_path}/*.gem"]
|
103
103
|
|
104
104
|
cached = cached.delete_if do |path|
|
105
|
-
spec =
|
105
|
+
spec = Gem::Format.from_file_by_path(path).spec
|
106
106
|
|
107
107
|
resolve.any? do |s|
|
108
108
|
s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git)
|
@@ -119,6 +119,55 @@ module Bundler
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
def clean
|
123
|
+
return false if Bundler.settings[:path] == nil
|
124
|
+
|
125
|
+
gem_bins = Dir["#{Gem.dir}/bin/*"]
|
126
|
+
git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
|
127
|
+
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
128
|
+
spec_gem_paths = specs.collect {|spec| spec.full_gem_path }
|
129
|
+
spec_gem_executables = specs.collect do |spec|
|
130
|
+
spec.executables.collect do |executable|
|
131
|
+
"#{Gem.dir}/#{spec.bindir}/#{executable}"
|
132
|
+
end
|
133
|
+
end.flatten
|
134
|
+
stale_gem_bins = gem_bins - spec_gem_executables
|
135
|
+
stale_git_dirs = git_dirs - spec_gem_paths
|
136
|
+
stale_gem_dirs = gem_dirs - spec_gem_paths
|
137
|
+
|
138
|
+
stale_gem_bins.each {|bin| FileUtils.rm(bin) }
|
139
|
+
stale_gem_dirs.collect do |gem_dir|
|
140
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
141
|
+
|
142
|
+
FileUtils.rm_rf(gem_dir)
|
143
|
+
specification_file = "#{Gem.dir}/specifications/#{full_name}.gemspec"
|
144
|
+
FileUtils.rm(specification_file) if File.exists?(specification_file)
|
145
|
+
|
146
|
+
parts = full_name.split('-')
|
147
|
+
name = parts[0..-2].join('-')
|
148
|
+
version = parts.last
|
149
|
+
output = "#{name} (#{version})"
|
150
|
+
|
151
|
+
Bundler.ui.info "Removing #{output}"
|
152
|
+
|
153
|
+
output
|
154
|
+
end + stale_git_dirs.collect do |gem_dir|
|
155
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
156
|
+
|
157
|
+
FileUtils.rm_rf(gem_dir)
|
158
|
+
|
159
|
+
parts = full_name.split('-')
|
160
|
+
name = parts[0..-3].join('-')
|
161
|
+
revision = parts[-1]
|
162
|
+
version = parts[-2]
|
163
|
+
output = "#{name} (#{version} #{revision})"
|
164
|
+
|
165
|
+
Bundler.ui.info "Removing #{output}"
|
166
|
+
|
167
|
+
output
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
122
171
|
private
|
123
172
|
|
124
173
|
def cache_path
|
@@ -127,7 +176,7 @@ module Bundler
|
|
127
176
|
|
128
177
|
def setup_environment
|
129
178
|
begin
|
130
|
-
ENV["BUNDLE_BIN_PATH"] =
|
179
|
+
ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION)
|
131
180
|
rescue Gem::GemNotFoundException
|
132
181
|
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
|
133
182
|
end
|
data/lib/bundler/settings.rb
CHANGED
@@ -16,7 +16,7 @@ module Bundler
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def delete(key)
|
19
|
-
@local_config
|
19
|
+
@local_config
|
20
20
|
end
|
21
21
|
|
22
22
|
def set_global(key, value)
|
@@ -62,7 +62,9 @@ module Bundler
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def without=(array)
|
65
|
-
|
65
|
+
unless array.empty?
|
66
|
+
self[:without] = array.join(":")
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
70
|
def without
|
@@ -77,7 +79,7 @@ module Bundler
|
|
77
79
|
if path = self[:path]
|
78
80
|
"#{path}/#{Bundler.ruby_scope}"
|
79
81
|
else
|
80
|
-
|
82
|
+
Gem.dir
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
@@ -104,7 +106,7 @@ module Bundler
|
|
104
106
|
end
|
105
107
|
|
106
108
|
def global_config_file
|
107
|
-
file = ENV["BUNDLE_CONFIG"] || File.join(
|
109
|
+
file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config")
|
108
110
|
Pathname.new(file)
|
109
111
|
end
|
110
112
|
|
data/lib/bundler/setup.rb
CHANGED
@@ -2,19 +2,12 @@ require 'bundler/shared_helpers'
|
|
2
2
|
|
3
3
|
if Bundler::SharedHelpers.in_bundle?
|
4
4
|
require 'bundler'
|
5
|
-
|
6
|
-
begin
|
7
|
-
Bundler.setup
|
8
|
-
rescue Bundler::BundlerError => e
|
9
|
-
puts "\e[31m#{e.message}\e[0m"
|
10
|
-
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
11
|
-
if Bundler::GemNotFound === e
|
12
|
-
puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
|
13
|
-
end
|
14
|
-
exit e.status_code
|
15
|
-
end
|
16
|
-
else
|
5
|
+
begin
|
17
6
|
Bundler.setup
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
puts "\e[31m#{e.message}\e[0m"
|
9
|
+
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
10
|
+
exit e.status_code
|
18
11
|
end
|
19
12
|
|
20
13
|
# Add bundler to the load path after disabling system gems
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'rubygems'
|
3
|
-
|
4
|
-
require 'bundler/rubygems_integration'
|
3
|
+
Gem.source_index # ensure Rubygems is fully loaded in Ruby 1.9
|
5
4
|
|
6
5
|
module Gem
|
7
6
|
class Dependency
|
@@ -58,14 +57,111 @@ module Bundler
|
|
58
57
|
if defined?(::Gem)
|
59
58
|
me = File.expand_path("../../", __FILE__)
|
60
59
|
$LOAD_PATH.reject! do |p|
|
61
|
-
next if File.expand_path(p) =~ /^#{
|
60
|
+
next if File.expand_path(p) =~ /^#{me}/
|
62
61
|
p != File.dirname(__FILE__) &&
|
63
|
-
|
62
|
+
Gem.path.any?{|gp| p =~ /^#{gp}/ }
|
64
63
|
end
|
65
64
|
$LOAD_PATH.uniq!
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
68
|
+
def reverse_rubygems_kernel_mixin
|
69
|
+
# Disable rubygems' gem activation system
|
70
|
+
::Kernel.class_eval do
|
71
|
+
if private_method_defined?(:gem_original_require)
|
72
|
+
alias rubygems_require require
|
73
|
+
alias require gem_original_require
|
74
|
+
end
|
75
|
+
|
76
|
+
undef gem
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def cripple_rubygems(specs)
|
81
|
+
reverse_rubygems_kernel_mixin
|
82
|
+
|
83
|
+
executables = specs.map { |s| s.executables }.flatten
|
84
|
+
Gem.source_index # ensure RubyGems is fully loaded
|
85
|
+
|
86
|
+
::Kernel.send(:define_method, :gem) do |dep, *reqs|
|
87
|
+
if executables.include? File.basename(caller.first.split(':').first)
|
88
|
+
return
|
89
|
+
end
|
90
|
+
opts = reqs.last.is_a?(Hash) ? reqs.pop : {}
|
91
|
+
|
92
|
+
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
93
|
+
dep = Gem::Dependency.new(dep, reqs)
|
94
|
+
end
|
95
|
+
|
96
|
+
spec = specs.find { |s| s.name == dep.name }
|
97
|
+
|
98
|
+
if spec.nil?
|
99
|
+
|
100
|
+
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
|
101
|
+
e.name = dep.name
|
102
|
+
if e.respond_to?(:requirement=)
|
103
|
+
e.requirement = dep.requirement
|
104
|
+
else
|
105
|
+
e.version_requirement = dep.requirement
|
106
|
+
end
|
107
|
+
raise e
|
108
|
+
elsif dep !~ spec
|
109
|
+
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
110
|
+
"Make sure all dependencies are added to Gemfile."
|
111
|
+
e.name = dep.name
|
112
|
+
if e.respond_to?(:requirement=)
|
113
|
+
e.requirement = dep.requirement
|
114
|
+
else
|
115
|
+
e.version_requirement = dep.requirement
|
116
|
+
end
|
117
|
+
raise e
|
118
|
+
end
|
119
|
+
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
# === Following hacks are to improve on the generated bin wrappers ===
|
124
|
+
|
125
|
+
# Yeah, talk about a hack
|
126
|
+
source_index_class = (class << Gem::SourceIndex ; self ; end)
|
127
|
+
source_index_class.send(:remove_method, :from_gems_in)
|
128
|
+
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
129
|
+
source_index = Gem::SourceIndex.new
|
130
|
+
source_index.spec_dirs = *args
|
131
|
+
source_index.add_specs(*specs)
|
132
|
+
source_index
|
133
|
+
end
|
134
|
+
|
135
|
+
# OMG more hacks
|
136
|
+
gem_class = (class << Gem ; self ; end)
|
137
|
+
gem_class.send(:remove_method, :refresh)
|
138
|
+
gem_class.send(:define_method, :refresh) { }
|
139
|
+
gem_class.send(:remove_method, :bin_path)
|
140
|
+
gem_class.send(:define_method, :bin_path) do |name, *args|
|
141
|
+
exec_name, *reqs = args
|
142
|
+
|
143
|
+
if exec_name == 'bundle'
|
144
|
+
return ENV['BUNDLE_BIN_PATH']
|
145
|
+
end
|
146
|
+
|
147
|
+
spec = nil
|
148
|
+
|
149
|
+
if exec_name
|
150
|
+
spec = specs.find { |s| s.executables.include?(exec_name) }
|
151
|
+
spec or raise Gem::Exception, "can't find executable #{exec_name}"
|
152
|
+
else
|
153
|
+
spec = specs.find { |s| s.name == name }
|
154
|
+
exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
|
155
|
+
end
|
156
|
+
|
157
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
158
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
159
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
160
|
+
end
|
161
|
+
|
162
|
+
Gem.clear_paths
|
163
|
+
end
|
164
|
+
|
69
165
|
extend self
|
70
166
|
end
|
71
167
|
end
|