bundler 1.0.12 → 1.0.13

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.

@@ -1,3 +1,18 @@
1
+ ## 1.0.13 (May 4, 2011)
2
+
3
+ Features:
4
+
5
+ - Compatibility with Rubygems master (soon to be v1.8) (@evanphx)
6
+ - Informative error when --path points to a broken symlink
7
+ - Support Rake 0.9 and greater (@e2)
8
+ - Output full errors for non-TTYs e.g. pow (@josh)
9
+
10
+ Bugfixes:
11
+
12
+ - Allow spaces in gem path names for gem tasks (@rslifka)
13
+ - Have cap run bundle install from release_path (@martinjagusch)
14
+ - Quote git refspec so zsh doesn't expand it (@goneflyin)
15
+
1
16
  ## 1.0.12 (April 8, 2011)
2
17
 
3
18
  Features:
@@ -8,7 +23,7 @@ Features:
8
23
 
9
24
  Bugfixes:
10
25
 
11
- - Compatibility with Rubygems 1.7 and Rails 2.3 and vendored gems (@evan)
26
+ - Compatibility with Rubygems 1.7 and Rails 2.3 and vendored gems (@evanphx)
12
27
  - Fix changing gem order in lock (@gucki)
13
28
  - Remove color escape sequences when displaying man pages (@bgreenlee)
14
29
  - Fix creating GEM_HOME on both JRuby 1.5 and 1.6 (@nickseiger)
data/Rakefile CHANGED
@@ -8,8 +8,8 @@ def sudo?
8
8
  end
9
9
 
10
10
  begin
11
+ # set up rspec tasks
11
12
  require 'rspec/core/rake_task'
12
- require 'ronn'
13
13
 
14
14
  desc "Run specs"
15
15
  RSpec::Core::RakeTask.new do |t|
@@ -71,17 +71,35 @@ begin
71
71
  unless File.directory?("tmp/rubygems")
72
72
  system("git clone git://github.com/rubygems/rubygems.git tmp/rubygems")
73
73
  end
74
+ hash = nil
75
+
74
76
  Dir.chdir("tmp/rubygems") do
75
77
  system("git remote update")
76
78
  system("git checkout #{rg}")
77
79
  system("git pull origin master") if rg == "master"
80
+ hash = `git rev-parse HEAD`.strip
78
81
  end
82
+
83
+ puts "Running bundler specs against rubygems '#{rg}' at #{hash}"
79
84
  ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems/lib")} #{rubyopt}"
80
85
  end
81
86
 
82
87
  task rg => "clone_rubygems_#{rg}"
83
88
  task "rubygems:all" => rg
84
89
  end
90
+
91
+ desc "Run specs under a Rubygems checkout (set RG=path)"
92
+ RSpec::Core::RakeTask.new("co") do |t|
93
+ t.rspec_opts = %w(-fs --color)
94
+ t.ruby_opts = %w(-w)
95
+ end
96
+
97
+ task "setup_co" do
98
+ ENV["RUBYOPT"] = "-I#{File.expand_path ENV['RG']} #{rubyopt}"
99
+ end
100
+
101
+ task "co" => "setup_co"
102
+ task "rubygems:all" => "co"
85
103
  end
86
104
 
87
105
  namespace :ruby do
@@ -111,6 +129,38 @@ begin
111
129
 
112
130
  end
113
131
 
132
+
133
+ # set up man tasks that use ronn
134
+ require 'ronn'
135
+
136
+ namespace :man do
137
+ directory "lib/bundler/man"
138
+
139
+ Dir["man/*.ronn"].each do |ronn|
140
+ basename = File.basename(ronn, ".ronn")
141
+ roff = "lib/bundler/man/#{basename}"
142
+
143
+ file roff => ["lib/bundler/man", ronn] do
144
+ sh "ronn --roff --pipe #{ronn} > #{roff}"
145
+ end
146
+
147
+ file "#{roff}.txt" => roff do
148
+ sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
149
+ end
150
+
151
+ task :build_all_pages => "#{roff}.txt"
152
+ end
153
+
154
+ desc "Build the man pages"
155
+ task :build => "man:build_all_pages"
156
+
157
+ desc "Clean up from the built man pages"
158
+ task :clean do
159
+ rm_rf "lib/bundler/man"
160
+ end
161
+ end
162
+
163
+
114
164
  rescue LoadError
115
165
  task :spec do
116
166
  abort "Run `rake spec:deps` to be able to run the specs"
@@ -126,33 +176,6 @@ rescue LoadError
126
176
 
127
177
  end
128
178
 
129
- namespace :man do
130
- directory "lib/bundler/man"
131
-
132
- Dir["man/*.ronn"].each do |ronn|
133
- basename = File.basename(ronn, ".ronn")
134
- roff = "lib/bundler/man/#{basename}"
135
-
136
- file roff => ["lib/bundler/man", ronn] do
137
- sh "ronn --roff --pipe #{ronn} > #{roff}"
138
- end
139
-
140
- file "#{roff}.txt" => roff do
141
- sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt"
142
- end
143
-
144
- task :build_all_pages => "#{roff}.txt"
145
- end
146
-
147
- desc "Build the man pages"
148
- task :build => "man:build_all_pages"
149
-
150
- desc "Clean up from the built man pages"
151
- task :clean do
152
- rm_rf "lib/bundler/man"
153
- end
154
- end
155
-
156
179
  namespace :vendor do
157
180
  desc "Build the vendor dir"
158
181
  task :build => :clean do
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  require 'yaml'
11
11
  require 'bundler/rubygems_ext'
12
+ require 'bundler/rubygems_integration'
12
13
  require 'bundler/version'
13
14
 
14
15
  module Bundler
@@ -85,7 +86,6 @@ module Bundler
85
86
  end
86
87
 
87
88
  def bundle_path
88
- # STDERR.puts settings.path
89
89
  @bundle_path ||= Pathname.new(settings.path).expand_path(root)
90
90
  end
91
91
 
@@ -138,11 +138,11 @@ module Bundler
138
138
  end
139
139
 
140
140
  def ruby_scope
141
- "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
141
+ "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
142
142
  end
143
143
 
144
144
  def user_bundle_path
145
- Pathname.new(Gem.user_home).join(".bundler")
145
+ Pathname.new(Bundler.rubygems.user_home).join(".bundler")
146
146
  end
147
147
 
148
148
  def home
@@ -259,8 +259,9 @@ module Bundler
259
259
  if settings[:disable_shared_gems]
260
260
  ENV['GEM_PATH'] = ''
261
261
  ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
262
- elsif Gem.dir != bundle_path.to_s
263
- paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
262
+ elsif Bundler.rubygems.gem_dir != bundle_path.to_s
263
+ possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
264
+ paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
264
265
  ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
265
266
  ENV["GEM_HOME"] = bundle_path.to_s
266
267
  end
@@ -268,7 +269,7 @@ module Bundler
268
269
  # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
269
270
  FileUtils.mkdir_p bundle_path.to_s rescue nil
270
271
 
271
- Gem.clear_paths
272
+ Bundler.rubygems.clear_paths
272
273
  end
273
274
 
274
275
  def upgrade_lockfile
@@ -4,9 +4,6 @@ require 'thor/actions'
4
4
  require 'rubygems/user_interaction'
5
5
  require 'rubygems/config_file'
6
6
 
7
- # Work around a RubyGems bug
8
- Gem.configuration
9
-
10
7
  module Bundler
11
8
  class CLI < Thor
12
9
  include Thor::Actions
@@ -16,7 +13,7 @@ module Bundler
16
13
  the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
17
14
  Bundler.ui = UI::Shell.new(the_shell)
18
15
  Bundler.ui.debug! if options["verbose"]
19
- Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
16
+ Bundler.rubygems.ui = UI::RGProxy.new(Bundler.ui)
20
17
  end
21
18
 
22
19
  check_unknown_options! unless ARGV.include?("exec") || ARGV.include?("config")
@@ -162,6 +159,7 @@ module Bundler
162
159
  end
163
160
  opts[:without].map!{|g| g.to_sym }
164
161
 
162
+ # Can't use Bundler.settings for this because settings needs gemfile.dirname
165
163
  ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
166
164
  ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
167
165
 
@@ -211,7 +209,6 @@ module Bundler
211
209
  opts[:system] = true
212
210
  end
213
211
 
214
- # Can't use Bundler.settings for this because settings needs gemfile.dirname
215
212
  Bundler.settings[:path] = nil if opts[:system]
216
213
  Bundler.settings[:path] = "vendor/bundle" if opts[:deployment]
217
214
  Bundler.settings[:path] = path if path
@@ -241,7 +238,7 @@ module Bundler
241
238
  "Please use `bundle install --path #{path}` instead."
242
239
  end
243
240
  rescue GemNotFound => e
244
- if opts[:local]
241
+ if opts[:local] && Bundler.app_cache.exist?
245
242
  Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
246
243
  end
247
244
 
@@ -61,7 +61,7 @@ module Bundler
61
61
  @unlock[:gems] ||= []
62
62
  @unlock[:sources] ||= []
63
63
 
64
- current_platform = Gem.platforms.map { |p| generic(p) }.compact.last
64
+ current_platform = Bundler.rubygems.platforms.map { |p| generic(p) }.compact.last
65
65
  @new_platform = !@platforms.include?(current_platform)
66
66
  @platforms |= [current_platform]
67
67
 
@@ -45,7 +45,7 @@ module Bundler
45
45
  args << bundle_flags.to_s
46
46
  args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
47
47
 
48
- run "#{bundle_cmd} install #{args.join(' ')}"
48
+ run "cd #{context.fetch(:current_release)} && #{bundle_cmd} install #{args.join(' ')}"
49
49
  end
50
50
  end
51
51
  end
@@ -2,6 +2,13 @@ $:.unshift File.expand_path('../vendor', __FILE__)
2
2
  require 'thor'
3
3
  require 'bundler'
4
4
 
5
+ begin
6
+ # Support Rake > 0.8.7
7
+ require 'rake/dsl_definition'
8
+ include Rake::DSL
9
+ rescue LoadError
10
+ end
11
+
5
12
  module Bundler
6
13
  class GemHelper
7
14
  def self.install_tasks(opts = {})
@@ -39,7 +46,7 @@ module Bundler
39
46
 
40
47
  def build_gem
41
48
  file_name = nil
42
- sh("gem build #{spec_path}") { |out, code|
49
+ sh("gem build '#{spec_path}'") { |out, code|
43
50
  raise out unless out[/Successfully/]
44
51
  file_name = File.basename(built_gem_path)
45
52
  FileUtils.mkdir_p(File.join(base, 'pkg'))
@@ -51,7 +58,7 @@ module Bundler
51
58
 
52
59
  def install_gem
53
60
  built_gem_path = build_gem
54
- out, _ = sh_with_code("gem install #{built_gem_path}")
61
+ out, _ = sh_with_code("gem install '#{built_gem_path}'")
55
62
  raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
56
63
  Bundler.ui.confirm "#{name} (#{version}) installed"
57
64
  end
@@ -68,7 +75,7 @@ module Bundler
68
75
 
69
76
  protected
70
77
  def rubygem_push(path)
71
- out, _ = sh("gem push #{path}")
78
+ out, _ = sh("gem push '#{path}'")
72
79
  raise "Gem push failed due to lack of RubyGems.org credentials." if out[/Enter your RubyGems.org credentials/]
73
80
  Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org"
74
81
  end
@@ -10,6 +10,14 @@ module Bundler
10
10
  end
11
11
 
12
12
  def run(options)
13
+ # Create the BUNDLE_PATH directory
14
+ begin
15
+ Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist?
16
+ rescue Errno::EEXIST
17
+ raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
18
+ "because of an invalid symlink. Remove the symlink so the directory can be created."
19
+ end
20
+
13
21
  if Bundler.settings[:frozen]
14
22
  @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
15
23
  end
@@ -35,9 +43,6 @@ module Bundler
35
43
  @definition.resolve_remotely!
36
44
  end
37
45
 
38
- # Ensure that BUNDLE_PATH exists
39
- Bundler.mkdir_p(Bundler.bundle_path) unless File.exist?(Bundler.bundle_path)
40
-
41
46
  # Must install gems in the order that the resolver provides
42
47
  # as dependencies might actually affect the installation of
43
48
  # the gem.
@@ -49,13 +54,9 @@ module Bundler
49
54
  # next
50
55
  # end
51
56
 
52
- begin
53
- old_args = Gem::Command.build_args
54
- Gem::Command.build_args = [Bundler.settings["build.#{spec.name}"]]
57
+ Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do
55
58
  spec.source.install(spec)
56
59
  Bundler.ui.debug "from #{spec.loaded_from} "
57
- ensure
58
- Gem::Command.build_args = old_args
59
60
  end
60
61
 
61
62
  Bundler.ui.info ""
@@ -39,6 +39,11 @@ module Gem
39
39
  end
40
40
  end
41
41
 
42
+ # RubyGems 1.8+ used only.
43
+ def gem_dir
44
+ full_gem_path
45
+ end
46
+
42
47
  def groups
43
48
  @groups ||= []
44
49
  end
@@ -0,0 +1,285 @@
1
+ module Bundler
2
+ class RubygemsIntegration
3
+ def initialize
4
+ # Work around a RubyGems bug
5
+ configuration
6
+ end
7
+
8
+ def loaded_specs(name)
9
+ Gem.loaded_specs[name]
10
+ end
11
+
12
+ def mark_loaded(spec)
13
+ Gem.loaded_specs[spec.name] = spec
14
+ end
15
+
16
+ def path(obj)
17
+ obj.to_s
18
+ end
19
+
20
+ def platforms
21
+ Gem.platforms
22
+ end
23
+
24
+ def configuration
25
+ Gem.configuration
26
+ end
27
+
28
+ def ruby_engine
29
+ Gem.ruby_engine
30
+ end
31
+
32
+ def read_binary(path)
33
+ Gem.read_binary(path)
34
+ end
35
+
36
+ def inflate(obj)
37
+ Gem.inflate(obj)
38
+ end
39
+
40
+ def sources=(val)
41
+ Gem.sources = val
42
+ end
43
+
44
+ def sources
45
+ Gem.sources
46
+ end
47
+
48
+ def gem_dir
49
+ Gem.dir.to_s
50
+ end
51
+
52
+ def gem_bindir
53
+ Gem.bindir
54
+ end
55
+
56
+ def user_home
57
+ Gem.user_home
58
+ end
59
+
60
+ def gem_path
61
+ # Make sure that Gem.path is an array of Strings, not some
62
+ # internal Rubygems object
63
+ Gem.path.map { |x| x.to_s }
64
+ end
65
+
66
+ def marshal_spec_dir
67
+ Gem::MARSHAL_SPEC_DIR
68
+ end
69
+
70
+ def clear_paths
71
+ Gem.clear_paths
72
+ end
73
+
74
+ def bin_path(gem, bin, ver)
75
+ Gem.bin_path(gem, bin, ver)
76
+ end
77
+
78
+ def ui=(obj)
79
+ Gem::DefaultUserInteraction.ui = obj
80
+ end
81
+
82
+ def fetch_specs(all, pre, &blk)
83
+ Gem::SpecFetcher.new.list(all, pre).each(&blk)
84
+ end
85
+
86
+ def with_build_args(args)
87
+ old_args = Gem::Command.build_args
88
+ begin
89
+ Gem::Command.build_args = args
90
+ yield
91
+ ensure
92
+ Gem::Command.build_args = old_args
93
+ end
94
+ end
95
+
96
+ def spec_from_gem(path)
97
+ Gem::Format.from_file_by_path(path).spec
98
+ end
99
+
100
+ def download_gem(spec, uri, path)
101
+ Gem::RemoteFetcher.fetcher.download(spec, uri, path)
102
+ end
103
+
104
+ def reverse_rubygems_kernel_mixin
105
+ # Disable rubygems' gem activation system
106
+ ::Kernel.class_eval do
107
+ if private_method_defined?(:gem_original_require)
108
+ alias rubygems_require require
109
+ alias require gem_original_require
110
+ end
111
+
112
+ undef gem
113
+ end
114
+ end
115
+
116
+ def replace_gem(specs)
117
+ executables = specs.map { |s| s.executables }.flatten
118
+
119
+ ::Kernel.send(:define_method, :gem) do |dep, *reqs|
120
+ if executables.include? File.basename(caller.first.split(':').first)
121
+ return
122
+ end
123
+ opts = reqs.last.is_a?(Hash) ? reqs.pop : {}
124
+
125
+ unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
126
+ dep = Gem::Dependency.new(dep, reqs)
127
+ end
128
+
129
+ spec = specs.find { |s| s.name == dep.name }
130
+
131
+ if spec.nil?
132
+
133
+ e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
134
+ e.name = dep.name
135
+ if e.respond_to?(:requirement=)
136
+ e.requirement = dep.requirement
137
+ else
138
+ e.version_requirement = dep.requirement
139
+ end
140
+ raise e
141
+ elsif dep !~ spec
142
+ e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
143
+ "Make sure all dependencies are added to Gemfile."
144
+ e.name = dep.name
145
+ if e.respond_to?(:requirement=)
146
+ e.requirement = dep.requirement
147
+ else
148
+ e.version_requirement = dep.requirement
149
+ end
150
+ raise e
151
+ end
152
+
153
+ true
154
+ end
155
+ end
156
+
157
+ def stub_source_index137(specs)
158
+ # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
159
+ source_index_class = (class << Gem::SourceIndex ; self ; end)
160
+ source_index_class.send(:remove_method, :from_gems_in)
161
+ source_index_class.send(:define_method, :from_gems_in) do |*args|
162
+ source_index = Gem::SourceIndex.new
163
+ source_index.spec_dirs = *args
164
+ source_index.add_specs(*specs)
165
+ source_index
166
+ end
167
+ end
168
+
169
+ def stub_source_index170(specs)
170
+ Gem::SourceIndex.send(:define_method, :initialize) do |*args|
171
+ @gems = {}
172
+ self.spec_dirs = *args
173
+ add_specs(*specs)
174
+ end
175
+ end
176
+
177
+ # Used to make bin stubs that are not created by bundler work
178
+ # under bundler. The new Gem.bin_path only considers gems in
179
+ # +specs+
180
+ def replace_bin_path(specs)
181
+ gem_class = (class << Gem ; self ; end)
182
+ gem_class.send(:remove_method, :bin_path)
183
+ gem_class.send(:define_method, :bin_path) do |name, *args|
184
+ exec_name, *reqs = args
185
+
186
+ if exec_name == 'bundle'
187
+ return ENV['BUNDLE_BIN_PATH']
188
+ end
189
+
190
+ spec = nil
191
+
192
+ if exec_name
193
+ spec = specs.find { |s| s.executables.include?(exec_name) }
194
+ spec or raise Gem::Exception, "can't find executable #{exec_name}"
195
+ else
196
+ spec = specs.find { |s| s.name == name }
197
+ exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
198
+ end
199
+
200
+ gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
201
+ gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
202
+ File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
203
+ end
204
+ end
205
+
206
+ # Because Bundler has a static view of what specs are available,
207
+ # we don't #reflesh, so stub it out.
208
+ def replace_refresh
209
+ gem_class = (class << Gem ; self ; end)
210
+ gem_class.send(:remove_method, :refresh)
211
+ gem_class.send(:define_method, :refresh) { }
212
+ end
213
+
214
+ # Replace or hook into Rubygems to provide a bundlerized view
215
+ # of the world.
216
+ def replace_entrypoints(specs)
217
+ reverse_rubygems_kernel_mixin
218
+
219
+ replace_gem(specs)
220
+
221
+ stub_rubygems(specs)
222
+
223
+ replace_bin_path(specs)
224
+ replace_refresh
225
+
226
+ Gem.clear_paths
227
+ end
228
+
229
+ class Modern < RubygemsIntegration
230
+ def stub_rubygems(specs)
231
+ Gem::Specification.all = specs
232
+
233
+ Gem.post_reset {
234
+ Gem::Specification.all = specs
235
+ }
236
+
237
+ stub_source_index170(specs)
238
+ end
239
+
240
+ def all_specs
241
+ Gem::Specification.to_a
242
+ end
243
+
244
+ def find_name(name)
245
+ Gem::Specification.find_all_by_name name
246
+ end
247
+
248
+ end
249
+
250
+ class Legacy < RubygemsIntegration
251
+ def stub_rubygems(specs)
252
+ stub_source_index137(specs)
253
+ end
254
+
255
+ def all_specs
256
+ Gem.source_index.all_gems.values
257
+ end
258
+
259
+ def find_name(name)
260
+ Gem.source_index.find_name(name)
261
+ end
262
+ end
263
+
264
+ class Transitional < Legacy
265
+ def stub_rubygems(specs)
266
+ stub_source_index170(specs)
267
+ end
268
+ end
269
+
270
+ end
271
+
272
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0')
273
+ if Gem::Specification.respond_to? :all=
274
+ @rubygems = RubygemsIntegration::Modern.new
275
+ else
276
+ @rubygems = RubygemsIntegration::Transitional.new
277
+ end
278
+ else
279
+ @rubygems = RubygemsIntegration::Legacy.new
280
+ end
281
+
282
+ class << self
283
+ attr_reader :rubygems
284
+ end
285
+ end
@@ -11,7 +11,7 @@ module Bundler
11
11
  specs = groups.any? ? @definition.specs_for(groups) : requested_specs
12
12
 
13
13
  setup_environment
14
- cripple_rubygems(specs)
14
+ Bundler.rubygems.replace_entrypoints(specs)
15
15
 
16
16
  # Activate the specs
17
17
  specs.each do |spec|
@@ -19,7 +19,7 @@ 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 = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version
22
+ if activated_spec = Bundler.rubygems.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
24
  "but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
25
25
  e.name = spec.name
@@ -31,7 +31,7 @@ module Bundler
31
31
  raise e
32
32
  end
33
33
 
34
- Gem.loaded_specs[spec.name] = spec
34
+ Bundler.rubygems.mark_loaded(spec)
35
35
  load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
36
36
  $LOAD_PATH.unshift(*load_paths)
37
37
  end
@@ -102,7 +102,7 @@ module Bundler
102
102
  cached = Dir["#{cache_path}/*.gem"]
103
103
 
104
104
  cached = cached.delete_if do |path|
105
- spec = Gem::Format.from_file_by_path(path).spec
105
+ spec = Bundler.rubygems.spec_from_gem path
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)
@@ -127,7 +127,7 @@ module Bundler
127
127
 
128
128
  def setup_environment
129
129
  begin
130
- ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION)
130
+ ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
131
131
  rescue Gem::GemNotFoundException
132
132
  ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
133
133
  end
@@ -79,7 +79,7 @@ module Bundler
79
79
  if path = self[:path]
80
80
  "#{path}/#{Bundler.ruby_scope}"
81
81
  else
82
- Gem.dir
82
+ Bundler.rubygems.gem_dir
83
83
  end
84
84
  end
85
85
 
@@ -106,7 +106,7 @@ module Bundler
106
106
  end
107
107
 
108
108
  def global_config_file
109
- file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config")
109
+ file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config")
110
110
  Pathname.new(file)
111
111
  end
112
112
 
@@ -2,12 +2,16 @@ require 'bundler/shared_helpers'
2
2
 
3
3
  if Bundler::SharedHelpers.in_bundle?
4
4
  require 'bundler'
5
- begin
5
+ if STDOUT.tty?
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
+ exit e.status_code
12
+ end
13
+ else
6
14
  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
11
15
  end
12
16
 
13
17
  # Add bundler to the load path after disabling system gems
@@ -1,6 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
- Gem.source_index # ensure Rubygems is fully loaded in Ruby 1.9
3
+
4
+ require 'bundler/rubygems_integration'
4
5
 
5
6
  module Gem
6
7
  class Dependency
@@ -59,118 +60,12 @@ module Bundler
59
60
  $LOAD_PATH.reject! do |p|
60
61
  next if File.expand_path(p) =~ /^#{me}/
61
62
  p != File.dirname(__FILE__) &&
62
- Gem.path.any?{|gp| p =~ /^#{gp}/ }
63
+ Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{gp}/ }
63
64
  end
64
65
  $LOAD_PATH.uniq!
65
66
  end
66
67
  end
67
68
 
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
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0')
127
- Gem::SourceIndex.send(:define_method, :initialize) do |*args|
128
- @gems = {}
129
- self.spec_dirs = *args
130
- add_specs(*specs)
131
- end
132
- else
133
- # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
134
- source_index_class = (class << Gem::SourceIndex ; self ; end)
135
- source_index_class.send(:remove_method, :from_gems_in)
136
- source_index_class.send(:define_method, :from_gems_in) do |*args|
137
- source_index = Gem::SourceIndex.new
138
- source_index.spec_dirs = *args
139
- source_index.add_specs(*specs)
140
- source_index
141
- end
142
- end
143
-
144
- # OMG more hacks
145
- gem_class = (class << Gem ; self ; end)
146
- gem_class.send(:remove_method, :refresh)
147
- gem_class.send(:define_method, :refresh) { }
148
- gem_class.send(:remove_method, :bin_path)
149
- gem_class.send(:define_method, :bin_path) do |name, *args|
150
- exec_name, *reqs = args
151
-
152
- if exec_name == 'bundle'
153
- return ENV['BUNDLE_BIN_PATH']
154
- end
155
-
156
- spec = nil
157
-
158
- if exec_name
159
- spec = specs.find { |s| s.executables.include?(exec_name) }
160
- spec or raise Gem::Exception, "can't find executable #{exec_name}"
161
- else
162
- spec = specs.find { |s| s.name == name }
163
- exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
164
- end
165
-
166
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
167
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
168
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
169
- end
170
-
171
- Gem.clear_paths
172
- end
173
-
174
69
  extend self
175
70
  end
176
71
  end
@@ -17,8 +17,12 @@ module Bundler
17
17
  @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) }
18
18
  @allow_remote = false
19
19
  @allow_cached = false
20
+
20
21
  # Hardcode the paths for now
21
- @caches = [ Bundler.app_cache ] + Gem.path.map { |p| File.expand_path("#{p}/cache") }
22
+ @caches = [ Bundler.app_cache ] + Bundler.rubygems.gem_path.map do |x|
23
+ File.expand_path("#{x}/cache")
24
+ end
25
+
22
26
  @spec_fetch_map = {}
23
27
  end
24
28
 
@@ -70,7 +74,7 @@ module Bundler
70
74
  spec, uri = @spec_fetch_map[spec.full_name]
71
75
  if spec
72
76
  path = download_gem_from_uri(spec, uri)
73
- s = Gem::Format.from_file_by_path(path).spec
77
+ s = Bundler.rubygems.spec_from_gem(path)
74
78
  spec.__swap__(s)
75
79
  end
76
80
  end
@@ -85,7 +89,7 @@ module Bundler
85
89
 
86
90
  Bundler.ui.info "Installing #{spec.name} (#{spec.version}) "
87
91
 
88
- install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir
92
+ install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir
89
93
  options = { :install_dir => install_path,
90
94
  :ignore_dependencies => true,
91
95
  :wrappers => true,
@@ -97,16 +101,16 @@ module Bundler
97
101
 
98
102
  # SUDO HAX
99
103
  if Bundler.requires_sudo?
100
- sudo "mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications"
101
- sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/"
102
- sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/"
104
+ sudo "mkdir -p #{Bundler.rubygems.gem_dir}/gems #{Bundler.rubygems.gem_dir}/specifications"
105
+ sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/"
106
+ sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/"
103
107
  spec.executables.each do |exe|
104
- sudo "mkdir -p #{Gem.bindir}"
105
- sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.bindir}"
108
+ sudo "mkdir -p #{Bundler.rubygems.gem_bindir}"
109
+ sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_bindir}"
106
110
  end
107
111
  end
108
112
 
109
- spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec"
113
+ spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec"
110
114
  end
111
115
 
112
116
  def sudo(str)
@@ -159,7 +163,7 @@ module Bundler
159
163
  @installed_specs ||= begin
160
164
  idx = Index.new
161
165
  have_bundler = false
162
- Gem.source_index.to_a.reverse.each do |dont_use_this_var, spec|
166
+ Bundler.rubygems.all_specs.reverse.each do |spec|
163
167
  next if spec.name == 'bundler' && spec.version.to_s != VERSION
164
168
  have_bundler = true if spec.name == 'bundler'
165
169
  spec.source = self
@@ -176,6 +180,7 @@ module Bundler
176
180
  s.version = VERSION
177
181
  s.platform = Gem::Platform::RUBY
178
182
  s.source = self
183
+ s.authors = ["bundler team"]
179
184
  s.loaded_from = File.expand_path("..", __FILE__)
180
185
  end
181
186
  idx << bundler
@@ -193,7 +198,7 @@ module Bundler
193
198
  next if gemfile =~ /bundler\-[\d\.]+?\.gem/
194
199
 
195
200
  begin
196
- s ||= Gem::Format.from_file_by_path(gemfile).spec
201
+ s ||= Bundler.rubygems.spec_from_gem(gemfile)
197
202
  rescue Gem::Package::FormatError
198
203
  raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted."
199
204
  end
@@ -209,7 +214,7 @@ module Bundler
209
214
  def remote_specs
210
215
  @remote_specs ||= begin
211
216
  idx = Index.new
212
- old = Gem.sources
217
+ old = Bundler.rubygems.sources
213
218
 
214
219
  remotes.each do |uri|
215
220
  Bundler.ui.info "Fetching source index for #{uri}"
@@ -226,7 +231,7 @@ module Bundler
226
231
  end
227
232
  idx
228
233
  ensure
229
- Gem.sources = old
234
+ Bundler.rubygems.sources = old
230
235
  end
231
236
  end
232
237
 
@@ -248,14 +253,14 @@ module Bundler
248
253
  def download_gem_from_uri(spec, uri)
249
254
  spec.fetch_platform
250
255
 
251
- download_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir
252
- gem_path = "#{Gem.dir}/cache/#{spec.full_name}.gem"
256
+ download_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir
257
+ gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
253
258
 
254
259
  FileUtils.mkdir_p("#{download_path}/cache")
255
- Gem::RemoteFetcher.fetcher.download(spec, uri, download_path)
260
+ Bundler.rubygems.download_gem(spec, uri, download_path)
256
261
 
257
262
  if Bundler.requires_sudo?
258
- sudo "mkdir -p #{Gem.dir}/cache"
263
+ sudo "mkdir -p #{Bundler.rubygems.gem_dir}/cache"
259
264
  sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}"
260
265
  end
261
266
 
@@ -349,6 +354,7 @@ module Bundler
349
354
  s.platform = Gem::Platform::RUBY
350
355
  s.summary = "Fake gemspec for #{@name}"
351
356
  s.relative_loaded_from = "#{@name}.gemspec"
357
+ s.authors = ["no one"]
352
358
  if expanded_path.join("bin").exist?
353
359
  binaries = expanded_path.join("bin").children
354
360
  binaries.reject!{|p| File.directory?(p) }
@@ -370,8 +376,8 @@ module Bundler
370
376
  class Installer < Gem::Installer
371
377
  def initialize(spec, options = {})
372
378
  @spec = spec
373
- @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Gem.dir}/bin"
374
- @gem_dir = spec.full_gem_path
379
+ @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Bundler.rubygems.gem_dir}/bin"
380
+ @gem_dir = Bundler.rubygems.path(spec.full_gem_path)
375
381
  @wrappers = options[:wrappers] || true
376
382
  @env_shebang = options[:env_shebang] || true
377
383
  @format_executable = options[:format_executable] || false
@@ -385,9 +391,9 @@ module Bundler
385
391
  end
386
392
  super
387
393
  if Bundler.requires_sudo?
388
- Bundler.mkdir_p "#{Gem.dir}/bin"
394
+ Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/bin"
389
395
  spec.executables.each do |exe|
390
- Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.dir}/bin/"
396
+ Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_dir}/bin/"
391
397
  end
392
398
  end
393
399
  end
@@ -2,5 +2,5 @@ module Bundler
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of bundler and we are unsure how to
4
4
  # handle this better.
5
- VERSION = "1.0.12" unless defined?(::Bundler::VERSION)
5
+ VERSION = "1.0.13" unless defined?(::Bundler::VERSION)
6
6
  end
@@ -185,10 +185,10 @@ describe "bundle flex_install" do
185
185
 
186
186
  it "does not install gems whose dependencies are not met" do
187
187
  bundle :install
188
- ruby <<-RUBY
188
+ ruby <<-RUBY, :expect_err => true
189
189
  require 'bundler/setup'
190
190
  RUBY
191
- out.should =~ /could not find gem 'rack-obama/i
191
+ err.should =~ /could not find gem 'rack-obama/i
192
192
  end
193
193
 
194
194
  it "suggests bundle update when the Gemfile requires different versions than the lock" do
@@ -15,3 +15,21 @@ describe "bundle install with deprecated features" do
15
15
  end
16
16
 
17
17
  end
18
+
19
+ describe "bundle install to a dead symlink" do
20
+ before do
21
+ in_app_root do
22
+ `ln -s /tmp/idontexist bundle`
23
+ end
24
+ end
25
+
26
+ it "reports the symlink is dead" do
27
+ gemfile <<-G
28
+ source "file://#{gem_repo1}"
29
+ gem "rack"
30
+ G
31
+
32
+ bundle "install --path bundle"
33
+ out.should =~ /invalid symlink/
34
+ end
35
+ end
@@ -27,7 +27,7 @@ describe "bundle lock with git gems" do
27
27
 
28
28
  it "provides correct #full_gem_path" do
29
29
  run <<-RUBY
30
- puts Gem.source_index.find_name('foo').first.full_gem_path
30
+ puts Bundler.rubygems.find_name('foo').first.full_gem_path
31
31
  RUBY
32
32
  out.should == bundle("show foo")
33
33
  end
@@ -83,7 +83,8 @@ describe "bundle exec" do
83
83
  gem "rack"
84
84
  G
85
85
 
86
- rubyopt = "-I#{bundler_path} -rbundler/setup"
86
+ rubyopt = ENV['RUBYOPT']
87
+ rubyopt = "-I#{bundler_path} -rbundler/setup #{rubyopt}"
87
88
 
88
89
  bundle "exec 'echo $RUBYOPT'"
89
90
  out.should have_rubyopts(rubyopt)
@@ -166,7 +166,7 @@ describe "Bundler.setup" do
166
166
  should_be_installed "rack 1.0.0"
167
167
  end
168
168
 
169
- describe "crippling rubygems" do
169
+ describe "integrate with rubygems" do
170
170
  describe "by replacing #gem" do
171
171
  before :each do
172
172
  install_gemfile <<-G
@@ -522,7 +522,7 @@ describe "Bundler.setup" do
522
522
 
523
523
  run <<-R
524
524
  Gem.refresh
525
- puts Gem.source_index.find_name("rack").inspect
525
+ puts Bundler.rubygems.find_name("rack").inspect
526
526
  R
527
527
 
528
528
  out.should == "[]"
@@ -39,8 +39,13 @@ RSpec.configure do |config|
39
39
  config.include Spec::Platforms
40
40
  config.include Spec::Sudo
41
41
 
42
+ if Spec::Sudo.test_sudo?
43
+ config.filter_run :sudo => true
44
+ else
45
+ config.filter_run_excluding :sudo => true
46
+ end
47
+
42
48
  config.filter_run :focused => true unless ENV['CI']
43
- config.filter_run_excluding :sudo => true unless Spec::Sudo.test_sudo?
44
49
  config.run_all_when_everything_filtered = true
45
50
  config.alias_example_to :fit, :focused => true
46
51
 
@@ -322,6 +322,9 @@ module Spec
322
322
 
323
323
  Array(versions).each do |version|
324
324
  spec = builder.new(self, name, version)
325
+ if !spec.authors or spec.authors.empty?
326
+ spec.authors = ["no one"]
327
+ end
325
328
  yield spec if block_given?
326
329
  spec._build(options)
327
330
  end
@@ -454,6 +457,8 @@ module Spec
454
457
  @files = _default_files.merge(@files)
455
458
  end
456
459
 
460
+ @spec.authors = ["no one"]
461
+
457
462
  @files.each do |file, source|
458
463
  file = Pathname.new(path).join(file)
459
464
  FileUtils.mkdir_p(file.dirname)
@@ -563,6 +568,11 @@ module Spec
563
568
  Dir.chdir(lib_path) do
564
569
  destination = opts[:path] || _default_path
565
570
  FileUtils.mkdir_p(destination)
571
+
572
+ if !@spec.authors or @spec.authors.empty?
573
+ @spec.authors = ["that guy"]
574
+ end
575
+
566
576
  Gem::Builder.new(@spec).build
567
577
  if opts[:to_system]
568
578
  `gem install --ignore-dependencies #{@spec.full_name}.gem`
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 12
10
- version: 1.0.12
9
+ - 13
10
+ version: 1.0.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Andr\xC3\xA9 Arko"
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-04-08 00:00:00 -07:00
21
+ date: 2011-05-04 00:00:00 -07:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ files:
85
85
  - lib/bundler/remote_specification.rb
86
86
  - lib/bundler/resolver.rb
87
87
  - lib/bundler/rubygems_ext.rb
88
+ - lib/bundler/rubygems_integration.rb
88
89
  - lib/bundler/runtime.rb
89
90
  - lib/bundler/settings.rb
90
91
  - lib/bundler/setup.rb