Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 448 lines (374 sloc) 13.997 kb
63b636b First pass at gemfile pack
Carlhuda authored
1 require 'fileutils'
ce350cc Get a simple bbl install working
Carlhuda authored
2 require 'pathname'
556a614 André Arko alphabetize-ish and fix require locations
indirect authored
3 require 'rbconfig'
f4dc6c5 Piotr Sarnacki Always try to keep original GEM_PATH
drogus authored
4 require 'bundler/gem_path_manipulation'
820bb93 Rename rubygems-ext to rubygems_ext
Carl Lerche authored
5 require 'bundler/rubygems_ext'
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
6 require 'bundler/rubygems_integration'
1da7eb3 Don't generate bundler.gemspec anymore
Carlhuda authored
7 require 'bundler/version'
1d393ab Kohei Suzuki Move constants to use it from SharedHelpers
eagletmt authored
8 require 'bundler/constants'
be64412 Hemant Kumar Extract Current Ruby version/platform detection from dependency.rb
gnufied authored
9 require 'bundler/current_ruby'
33154fd Joshua Hull Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
10
152a50a Rename gemfile back to bundler
Carl Lerche authored
11 module Bundler
f4dc6c5 Piotr Sarnacki Always try to keep original GEM_PATH
drogus authored
12 preserve_gem_path
33154fd Joshua Hull Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
13 ORIGINAL_ENV = ENV.to_hash
67859e4 Moving in thor
Carlhuda authored
14
7245613 Tim Moore Strip credentials from ambiguous source warnings.
TimMoore authored
15 autoload :AnonymizableURI, 'bundler/anonymizable_uri'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
16 autoload :Definition, 'bundler/definition'
17 autoload :Dependency, 'bundler/dependency'
2cc305a André Arko pull GemHelpers and MatchPlatform modules into files
indirect authored
18 autoload :DepProxy, 'bundler/dep_proxy'
32bcab3 André Arko pull out Deprecate so we can suppress output
indirect authored
19 autoload :Deprecate, 'bundler/deprecate'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
20 autoload :Dsl, 'bundler/dsl'
21 autoload :EndpointSpecification, 'bundler/endpoint_specification'
22 autoload :Environment, 'bundler/environment'
ebd9315 André Arko bundle env command (inspired by @Peeja)
indirect authored
23 autoload :Env, 'bundler/env'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
24 autoload :Fetcher, 'bundler/fetcher'
25 autoload :GemHelper, 'bundler/gem_helper'
2cc305a André Arko pull GemHelpers and MatchPlatform modules into files
indirect authored
26 autoload :GemHelpers, 'bundler/gem_helpers'
ccfa996 André Arko Merge fixes for Rubygems 1.8.10.dev from branch '1-0-stable'
indirect authored
27 autoload :GemInstaller, 'bundler/gem_installer'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
28 autoload :Graph, 'bundler/graph'
29 autoload :Index, 'bundler/index'
30 autoload :Installer, 'bundler/installer'
7a61d7b André Arko injector class to handle gem injection
indirect authored
31 autoload :Injector, 'bundler/injector'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
32 autoload :LazySpecification, 'bundler/lazy_specification'
33 autoload :LockfileParser, 'bundler/lockfile_parser'
2cc305a André Arko pull GemHelpers and MatchPlatform modules into files
indirect authored
34 autoload :MatchPlatform, 'bundler/match_platform'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
35 autoload :RemoteSpecification, 'bundler/remote_specification'
36 autoload :Resolver, 'bundler/resolver'
dc7dd9a Richard Schneeman Retry fetch specs with `--retry`
schneems authored
37 autoload :Retry, 'bundler/retry'
384c72c Terence Lee refactor ruby version into it's own class
hone authored
38 autoload :RubyVersion, 'bundler/ruby_version'
9db6c21 Terence Lee extract ruby method in Dsl into its own module
hone authored
39 autoload :RubyDsl, 'bundler/ruby_dsl'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
40 autoload :Runtime, 'bundler/runtime'
41 autoload :Settings, 'bundler/settings'
42 autoload :SharedHelpers, 'bundler/shared_helpers'
43 autoload :SpecSet, 'bundler/spec_set'
44 autoload :Source, 'bundler/source'
edccf04 Tim Moore Extract SourceList class from Definition.
TimMoore authored
45 autoload :SourceList, 'bundler/source_list'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
46 autoload :Specification, 'bundler/shared_helpers'
04a0dd8 add SystemRubyVersion to check against
Yehuda Katz and Terence Lee authored
47 autoload :SystemRubyVersion, 'bundler/ruby_version'
207179d Terence Lee put endpoint dependency info into a bundler spec
hone authored
48 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
49
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
50 class BundlerError < StandardError
7c5e545 André Arko Better gem install failure error, no backtrace
indirect authored
51 def self.status_code(code)
0ae574c DslError should inherit from Bundler::Error so its exceptions are caught...
Carlhuda authored
52 define_method(:status_code) { code }
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
53 end
54 end
55
896d954 Hemant Kumar Changed cyclic dependency error message
gnufied authored
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
2f15c3c André Arko remove exit code conflict with VersionConflict
indirect authored
60 class InstallHookError < BundlerError; status_code(8) ; end
896d954 Hemant Kumar Changed cyclic dependency error message
gnufied authored
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
ff26938 Hemant Kumar Raise user friendly errors in case of Cyclic Dependency
gnufied authored
71 class CyclicDependencyError < BundlerError; status_code(21) ; end
f66b49e Josef Šimánek Don't blow on bundle update gem when lock is not present.
simi authored
72 class GemfileLockNotFound < BundlerError; status_code(22) ; end
67859e4 Moving in thor
Carlhuda authored
73
4c3b339 André Arko Fantastic and also useful update instructions for outdated Bundler confl...
indirect authored
74 # Internal errors, should be rescued
3edfddb Hacked together some crap that doesn't really work
Carl Lerche authored
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
8511403 Ryunosuke SATO Remove unused class `Bundler::InvalidSpecSet`
tricknotes authored
86 class MarshalError < StandardError; end
cf736cf Use the Lockfile's specs as LazySpecifications instead of converting the...
Carl Lerche authored
87
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
88 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
89 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
90
91 def configure
239e2a0 André Arko handle blank GEM_HOMEs, too
indirect authored
92 @configured ||= configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
93 end
434fb42 First pass at output
Carlhuda authored
94
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
95 def ui
5e38e2d André Arko extract UI::Silent
indirect authored
96 @ui ||= UI::Silent.new
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
97 end
434fb42 First pass at output
Carlhuda authored
98
b4f4437 Ryan Bigg Add basic documentation for bin_path and bundle_path
radar authored
99 # Returns absolute path of where gems are installed on the filesystem.
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
100 def bundle_path
5b2d02f Make bundle install [PATH] namespace its gems to specific rubies
Carlhuda authored
101 @bundle_path ||= Pathname.new(settings.path).expand_path(root)
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
102 end
103
b4f4437 Ryan Bigg Add basic documentation for bin_path and bundle_path
radar authored
104 # Returns absolute location of where binstubs are installed to.
5f26a03 Have bundler generate executable stubs into ~/.bundler/bin that will aut...
Carl Lerche authored
105 def bin_path
106 @bin_path ||= begin
25ab2dc Make generating bin stubs an option
Carl Lerche authored
107 path = settings[:bin] || "bin"
4ff5d84 André Arko don't need to path up a path
indirect authored
108 path = Pathname.new(path).expand_path(root).expand_path
0891a38 Santiago Pastorino Revert "Don't try to create dirs if they already exists"
spastorino authored
109 FileUtils.mkdir_p(path)
4ff5d84 André Arko don't need to path up a path
indirect authored
110 path
5f26a03 Have bundler generate executable stubs into ~/.bundler/bin that will aut...
Carl Lerche authored
111 end
112 end
113
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
114 def setup(*groups)
5ff5cbc André Arko Tests and fix for Bundler.require removing gems from
indirect authored
115 # Just return if all groups are already loaded
116 return @setup if defined?(@setup)
2c8d6ae André Arko Don't call #setup after loading env.rb in Bundler.load
indirect authored
117
018a3c3 Terence Lee ruby version check for bundle#console and Bundler.setup
hone authored
118 definition.validate_ruby!
119
5dfc54c André Arko Don't call exit! if Bundler.setup has an exception
indirect authored
120 if groups.empty?
121 # Load all groups, but only once
122 @setup = load.setup
123 else
e2e60c2 André Arko clean up setup
indirect authored
124 @completed_groups ||= []
5dfc54c André Arko Don't call exit! if Bundler.setup has an exception
indirect authored
125 # Figure out which groups haven't been loaded yet
e2e60c2 André Arko clean up setup
indirect authored
126 unloaded = groups - @completed_groups
5dfc54c André Arko Don't call exit! if Bundler.setup has an exception
indirect authored
127 # Record groups that are now loaded
c3b93d3 André Arko Allow groups to be loaded again if they been cleared
indirect authored
128 @completed_groups = groups
671141d radsaq Don't hose existing load paths if Bundle.setup is called a multiple time...
radsaq authored
129 unloaded.any? ? load.setup(*groups) : load
4980111 André Arko Fix Bundler.setup so it can be called more than once safely
indirect authored
130 end
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
131 end
ce350cc Get a simple bbl install working
Carlhuda authored
132
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
133 def require(*groups)
69acfd8 André Arko Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
134 setup(*groups).require(*groups)
a8cbf77 Jeremy Kemper Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
135 end
136
625818a André Arko Clean up bundler.rb a bit
indirect authored
137 def load
91c74f4 Bundle.load and Bundle.runtime are the same thing again.
Carl Lerche authored
138 @load ||= Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
139 end
67859e4 Moving in thor
Carlhuda authored
140
3687843 Kevin Moore check only needs Environment (not Runtime)
kevmoo authored
141 def environment
142 Bundler::Environment.new(root, definition)
143 end
144
c0fbe04 Hemant Kumar Add some documentation about definition class
gnufied authored
145 # Returns an instance of Bundler::Definition for given Gemfile and lockfile
146 #
147 # @param unlock [Hash, Boolean, nil] Gems that have been requested
148 # to be updated or true if all gems should be updated
149 # @return [Bundler::Definition]
8a4dc7a Remove a little bit of crazy from Definition
Carl Lerche authored
150 def definition(unlock = nil)
151 @definition = nil if unlock
2b9094e Scope specs in the lock file by source
Carl Lerche authored
152 @definition ||= begin
153 configure
e0e79df André Arko Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
154 upgrade_lockfile
251b9c7 Use the Gemfile's name as a base for Gemfile.lock
Carl Lerche authored
155 Definition.build(default_gemfile, default_lockfile, unlock)
2b9094e Scope specs in the lock file by source
Carl Lerche authored
156 end
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from flex_i...
Carlhuda authored
157 end
158
b89e304 André Arko extract Bundler.locked_gems
indirect authored
159 def locked_gems
43732e9 Joyce H Displays the previous version of the gem when run bundle update
joyicecloud authored
160 return @locked_gems if defined?(@locked_gems)
161 if Bundler.default_lockfile.exist?
b89e304 André Arko extract Bundler.locked_gems
indirect authored
162 lock = Bundler.read_file(Bundler.default_lockfile)
fe86617 Tim Moore Fix typo lock_gems -> locked_gems.
TimMoore authored
163 @locked_gems = LockfileParser.new(lock)
43732e9 Joyce H Displays the previous version of the gem when run bundle update
joyicecloud authored
164 else
165 @locked_gems = nil
b89e304 André Arko extract Bundler.locked_gems
indirect authored
166 end
167 end
168
eda7324 Yehuda Katz Git should never use sudo
wycats authored
169 def ruby_scope
76fa378 André Arko move ConfigMap into RubygemsIntegration
indirect authored
170 "#{Bundler.rubygems.ruby_engine}/#{Bundler.rubygems.config_map[:ruby_version]}"
eda7324 Yehuda Katz Git should never use sudo
wycats authored
171 end
172
173 def user_bundle_path
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
174 Pathname.new(Bundler.rubygems.user_home).join(".bundler")
eda7324 Yehuda Katz Git should never use sudo
wycats authored
175 end
176
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
177 def home
625818a André Arko Clean up bundler.rb a bit
indirect authored
178 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
179 end
f31835e More work towards awesomeness
Carlhuda authored
180
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
181 def install_path
182 home.join("gems")
183 end
0d2492d Add more stuff for git
Carl Lerche authored
184
0d92de7 André Arko Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
185 def specs_path
186 bundle_path.join("specifications")
187 end
188
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
189 def cache
0d92de7 André Arko Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
190 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
191 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
192
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
193 def root
d1c0f0b Dean Holdren `bundle config --local gemfile /foo/bar/MyGemfile` now works
dholdren authored
194 @root ||= begin
195 default_gemfile.dirname.expand_path
196 rescue GemfileNotFound
197 bundle_dir = default_bundle_dir
198 raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
199 Pathname.new(File.expand_path("..", bundle_dir))
200 end
2d87c36 Move <root>/vendor/cache to a Bundler class method
Carl Lerche authored
201 end
202
27800e7 Provide an environment variable to allow customizing the location of <ap...
Carl Lerche authored
203 def app_config_path
204 ENV['BUNDLE_APP_CONFIG'] ?
205 Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) :
206 root.join('.bundle')
207 end
208
ce668a1 Gabriel Jaldon --path changes directory where 'vendor/cache' is created
gjaldon authored
209 def app_cache(custom_path = nil)
210 path = custom_path || root
3c6c010 André Arko allow cache path to be configured
indirect authored
211 path.join(self.settings.app_cache_path)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
212 end
213
bec906d André Arko er, one tmp per install run. yeah.
indirect authored
214 def tmp(name = Process.pid.to_s)
215 @tmp ||= Pathname.new Dir.mktmpdir("bundler")
216 @tmp.join(name)
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by ro...
Carl Lerche authored
217 end
218
e7f2855 Felix C. Stegerman cleanup tempdir
obfusk authored
219 def cleanup
220 FileUtils.remove_entry_secure(@tmp) if @tmp
2153fd4 André Arko ensure that cleanup won’t raise another exception
indirect authored
221 rescue
e7f2855 Felix C. Stegerman cleanup tempdir
obfusk authored
222 end
223
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
224 def settings
2cd5993 André Arko guarantee Bundler.settings will only parse once
indirect authored
225 return @settings if defined?(@settings)
226 @settings = Settings.new(app_config_path)
227 rescue GemfileNotFound
d1c0f0b Dean Holdren `bundle config --local gemfile /foo/bar/MyGemfile` now works
dholdren authored
228 @settings = Settings.new(Pathname.new(".bundle").expand_path)
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
229 end
230
5cf3fde Jonathan Dance with_clean_env clears bundler env vars
wuputah authored
231 def with_original_env
33154fd Joshua Hull Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
232 bundled_env = ENV.to_hash
233 ENV.replace(ORIGINAL_ENV)
234 yield
235 ensure
236 ENV.replace(bundled_env.to_hash)
237 end
238
5cf3fde Jonathan Dance with_clean_env clears bundler env vars
wuputah authored
239 def with_clean_env
240 with_original_env do
439f8d1 Suraj N. Kurapati set $MANPATH in Bundler::Runtime#setup_environment
sunaku authored
241 ENV['MANPATH'] = ENV['BUNDLE_ORIG_MANPATH']
5cf3fde Jonathan Dance with_clean_env clears bundler env vars
wuputah authored
242 ENV.delete_if { |k,_| k[0,7] == 'BUNDLE_' }
691c8ac Eric Anderson Avoid passing RUBYOPT changes in with_clean_env block.
eric1234 authored
243 if ENV.has_key? 'RUBYOPT'
244 ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
245 ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
246 end
5cf3fde Jonathan Dance with_clean_env clears bundler env vars
wuputah authored
247 yield
248 end
249 end
250
926836d Jonathan Dance add Bundler.clean_system and Bundler.clean_exec
wuputah authored
251 def clean_system(*args)
252 with_clean_env { Kernel.system(*args) }
253 end
254
255 def clean_exec(*args)
256 with_clean_env { Kernel.exec(*args) }
257 end
258
fb1e725 Make bundler/setup something you can add to your .profile. To do this, a...
Carlhuda authored
259 def default_gemfile
260 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
261 end
262
251b9c7 Use the Gemfile's name as a base for Gemfile.lock
Carl Lerche authored
263 def default_lockfile
264 SharedHelpers.default_lockfile
265 end
266
d1c0f0b Dean Holdren `bundle config --local gemfile /foo/bar/MyGemfile` now works
dholdren authored
267 def default_bundle_dir
268 SharedHelpers.default_bundle_dir
269 end
270
af6badf André Arko Add Bundler.system_bindir, defaulted to Gem.bindir
indirect authored
271 def system_bindir
272 # Gem.bindir doesn't always return the location that Rubygems will install
80b2d24 André Arko use Bundler.system_gems even when sudo is needed
indirect authored
273 # system binaries. If you put '-n foo' in your .gemrc, Rubygems will
af6badf André Arko Add Bundler.system_bindir, defaulted to Gem.bindir
indirect authored
274 # install binstubs there instead. Unfortunately, Rubygems doesn't expose
275 # that directory at all, so rather than parse .gemrc ourselves, we allow
276 # the directory to be set as well, via `bundle config bindir foo`.
80b2d24 André Arko use Bundler.system_gems even when sudo is needed
indirect authored
277 Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
af6badf André Arko Add Bundler.system_bindir, defaulted to Gem.bindir
indirect authored
278 end
279
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by ro...
Carl Lerche authored
280 def requires_sudo?
3fc6be1 André Arko improve sudo install support
indirect authored
281 return @requires_sudo if defined?(@requires_sudo_ran)
47e08d4 André Arko Memoize Bundler#requires_sudo? (thanks @tmm1)
indirect authored
282
3fc6be1 André Arko improve sudo install support
indirect authored
283 if settings.allow_sudo?
284 sudo_present = which "sudo"
285 end
286
287 if sudo_present
288 # the bundle path and subdirectories need to be writable for Rubygems
289 # to be able to unpack and install gems without exploding
290 path = bundle_path
291 path = path.parent until path.exist?
292
293 # bins are written to a different location on OS X
294 bin_dir = Pathname.new(Bundler.system_bindir)
295 bin_dir = bin_dir.parent until bin_dir.exist?
296
297 # if any directory is not writable, we need sudo
6841aff Smit Shah We still need to check if other directories are writable or not
Who828 authored
298 files = [path, bin_dir] | Dir[path.join('build_info/*').to_s] | Dir[path.join('*').to_s]
7e577f6 Smit Shah Just check all the files in build_info
Who828 authored
299 sudo_needed = files.any?{|f| !File.writable?(f) }
3fc6be1 André Arko improve sudo install support
indirect authored
300 end
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
301
3fc6be1 André Arko improve sudo install support
indirect authored
302 @requires_sudo_ran = true
303 @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
304 end
305
306 def mkdir_p(path)
307 if requires_sudo?
5bad314 Santiago Pastorino Avoid calling mkdir with sudo when not needed, you don't want to be aske...
spastorino authored
308 sudo "mkdir -p '#{path}'" unless File.exist?(path)
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
309 else
310 FileUtils.mkdir_p(path)
0891a38 Santiago Pastorino Revert "Don't try to create dirs if they already exists"
spastorino authored
311 end
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
312 end
313
26fa77a Erik Michaels-Ober Not all executables are binary
sferik authored
314 def which(executable)
628927b Linda_pp Fix Bundler::which
rhysd authored
315 if File.file?(executable) && File.executable?(executable)
26fa77a Erik Michaels-Ober Not all executables are binary
sferik authored
316 executable
17e7f34 André Arko Check for nil PATH
indirect authored
317 elsif ENV['PATH']
1e82d7f André Arko fix shadowed variable warning
indirect authored
318 path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
5af4efe Vijay Dev fix warning of variable shadowing
vijaydev authored
319 File.executable?(File.join(p, executable))
1e82d7f André Arko fix shadowed variable warning
indirect authored
320 end
26fa77a Erik Michaels-Ober Not all executables are binary
sferik authored
321 path && File.expand_path(executable, path)
d3a69d3 Aaron Patterson Search $PATH for a binary rather than shelling out to `which`
tenderlove authored
322 end
323 end
324
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
325 def sudo(str)
41476e2 Alexey Zapparov Improves sudo propmt
ixti authored
326 prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, '').strip + " "
327 Your user account isn't allowed to install to the system Rubygems.
328 You can cancel this installation and run:
329
330 bundle install --path vendor/bundle
331
332 to install the gems into ./vendor/bundle/, or you can enter your password
333 and install the bundled gems to Rubygems using sudo.
334
335 Password:
336 PROMPT
337
338 `sudo -p "#{prompt}" #{str}`
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by ro...
Carl Lerche authored
339 end
340
94bad63 Yehuda Katz 1.8 doesn't support :mode
wycats authored
341 def read_file(file)
1837d67 Yehuda Katz Fix warnings in bundler
wycats authored
342 File.open(file, "rb") { |f| f.read }
94bad63 Yehuda Katz 1.8 doesn't support :mode
wycats authored
343 end
344
bfc0632 André Arko abstract Marshal.load failures
indirect authored
345 def load_marshal(data)
346 Marshal.load(data)
347 rescue => e
348 raise MarshalError, "#{e.class}: #{e.message}"
349 end
350
681a5cb André Arko Factor out Bundler.load_gemspec so Source::Path and GemHelper can use it
indirect authored
351 def load_gemspec(file)
26637b7 David Kellum Resurrect "Add simple cache to Bundler.load_gemspec"
dekellum authored
352 @gemspec_cache ||= {}
0310e95 David Kellum Fix for spec failure introduced in d24e788a, with gemspec cache.
dekellum authored
353 key = File.expand_path(file)
354 spec = ( @gemspec_cache[key] ||= load_gemspec_uncached(file) )
355 # Protect against caching side-effected gemspecs by returning a
356 # new instance each time.
357 spec.dup if spec
26637b7 David Kellum Resurrect "Add simple cache to Bundler.load_gemspec"
dekellum authored
358 end
359
360 def load_gemspec_uncached(file)
681a5cb André Arko Factor out Bundler.load_gemspec so Source::Path and GemHelper can use it
indirect authored
361 path = Pathname.new(file)
c9b74e6 André Arko clean up load_gemspec a bit, organize specs
indirect authored
362 # Eval the gemspec from its parent directory, because some gemspecs
363 # depend on "./" relative paths.
4be789d Kohei Suzuki Prohibit Dir.pwd while another thread is doing Dir.chdir
eagletmt authored
364 SharedHelpers.chdir(path.dirname.to_s) do
c9b74e6 André Arko clean up load_gemspec a bit, organize specs
indirect authored
365 contents = path.read
366 if contents[0..2] == "---" # YAML header
367 eval_yaml_gemspec(path, contents)
d1b6ced Aaron Patterson only parse specs as YAML if they look like YAML files, otherwise fall
tenderlove authored
368 else
369 eval_gemspec(path, contents)
681a5cb André Arko Factor out Bundler.load_gemspec so Source::Path and GemHelper can use it
indirect authored
370 end
371 end
372 end
373
9a7099e André Arko argh, accidentally changed method name
indirect authored
374 def clear_gemspec_cache
32dfee4 Terence Lee instance_variable_set is ugly, turn it into a method
hone authored
375 @gemspec_cache = {}
376 end
377
7bd8264 Joyce H Print a better error when git is not installed.
joyicecloud authored
378 def git_present?
f894bdf André Arko look for windows git too
indirect authored
379 return @git_present if defined?(@git_present)
380 @git_present = Bundler.which("git") || Bundler.which("git.exe")
7bd8264 Joyce H Print a better error when git is not installed.
joyicecloud authored
381 end
382
5efd1c5 André Arko extract into Bundler.ruby_version
indirect authored
383 def ruby_version
384 @ruby_version ||= SystemRubyVersion.new
385 end
386
f3588cf Ash Wilson Bundler.reset! nukes the global Definition.
smashwilson authored
387 def reset!
388 @definition = nil
389 end
390
9ef6aa6 André Arko Disable rubygems more fully when unlocked
indirect authored
391 private
392
c9b74e6 André Arko clean up load_gemspec a bit, organize specs
indirect authored
393 def eval_yaml_gemspec(path, contents)
394 # If the YAML is invalid, Syck raises an ArgumentError, and Psych
395 # raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
396 Gem::Specification.from_yaml(contents)
397 rescue YamlSyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
398 eval_gemspec(path, contents)
399 end
400
d1b6ced Aaron Patterson only parse specs as YAML if they look like YAML files, otherwise fall
tenderlove authored
401 def eval_gemspec(path, contents)
402 eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
d0ad86f André Arko Ruby has an exception hierarchy! Who knew?
indirect authored
403 rescue ScriptError, StandardError => e
d1b6ced Aaron Patterson only parse specs as YAML if they look like YAML files, otherwise fall
tenderlove authored
404 original_line = e.backtrace.find { |line| line.include?(path.to_s) }
d0ad86f André Arko Ruby has an exception hierarchy! Who knew?
indirect authored
405 msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
d1b6ced Aaron Patterson only parse specs as YAML if they look like YAML files, otherwise fall
tenderlove authored
406 msg << " from\n #{original_line}" if original_line
407 msg << "\n"
408
409 if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
410 msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
411 end
412
413 raise GemspecError, msg
414 end
415
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
416 def configure_gem_home_and_path
239e2a0 André Arko handle blank GEM_HOMEs, too
indirect authored
417 blank_home = ENV['GEM_HOME'].nil? || ENV['GEM_HOME'].empty?
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
418 if settings[:disable_shared_gems]
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
419 ENV['GEM_PATH'] = ''
239e2a0 André Arko handle blank GEM_HOMEs, too
indirect authored
420 elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s
5f4a8f3 Phase 1 of rubygems/bundler reintegration
Evan Phoenix authored
421 possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
422 paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
55509f2 André Arko Ignore paths like GEM_HOME that are empty strings
indirect authored
423 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
a132e47 Aaron Patterson do not clear RG cache unless we actually modify GEM_PATH and GEM_HOME
tenderlove authored
424 end
bdaf3b8 Josef Šimánek Raise GemfileLockNotFound only for non-full update.
simi authored
425
44ff94f Sanjiv remove the duplicate code configure_gem and put it after if and else con...
narutosanjiv authored
426 configure_gem_home
239e2a0 André Arko handle blank GEM_HOMEs, too
indirect authored
427 bundle_path
428 end
429
430 def configure_gem_home
431 # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
432 FileUtils.mkdir_p bundle_path.to_s rescue nil
433
434 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
435 Bundler.rubygems.clear_paths
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
436 end
e0e79df André Arko Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
437
438 def upgrade_lockfile
251b9c7 Use the Gemfile's name as a base for Gemfile.lock
Carl Lerche authored
439 lockfile = default_lockfile
e0e79df André Arko Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
440 if lockfile.exist? && lockfile.read(3) == "---"
91c3beb André Arko Back to deleting old lockfiles for the beta release
indirect authored
441 Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
442 lockfile.rmtree
e0e79df André Arko Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
443 end
444 end
445
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
446 end
a8cbf77 Jeremy Kemper Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
447 end
Something went wrong with that request. Please try again.