Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 250 lines (206 sloc) 6.623 kB
63b636b First pass at gemfile pack
Carlhuda authored
1 require 'fileutils'
ce350cc Get a simple bbl install working
Carlhuda authored
2 require 'pathname'
88741e6 First pass at bbl lock
Carlhuda authored
3 require 'yaml'
820bb93 Rename rubygems-ext to rubygems_ext
Carl Lerche authored
4 require 'bundler/rubygems_ext'
1da7eb3 Don't generate bundler.gemspec anymore
Carlhuda authored
5 require 'bundler/version'
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
6
152a50a Rename gemfile back to bundler
Carl Lerche authored
7 module Bundler
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
8 ORIGINAL_ENV = ENV.to_hash
67859e4 Moving in thor
Carlhuda authored
9
152a50a Rename gemfile back to bundler
Carl Lerche authored
10 autoload :Definition, 'bundler/definition'
11 autoload :Dependency, 'bundler/dependency'
12 autoload :Dsl, 'bundler/dsl'
13 autoload :Environment, 'bundler/environment'
f414889 @kevmoo 'bundle viz'
kevmoo authored
14 autoload :Graph, 'bundler/graph'
152a50a Rename gemfile back to bundler
Carl Lerche authored
15 autoload :Index, 'bundler/index'
16 autoload :Installer, 'bundler/installer'
f779dee First pass at lockfile parser
Carlhuda authored
17 autoload :LazySpecification, 'bundler/lazy_specification'
ba579f4 Remove temporary flex stuff
Carlhuda authored
18 autoload :LockfileParser, 'bundler/lockfile_parser'
152a50a Rename gemfile back to bundler
Carl Lerche authored
19 autoload :RemoteSpecification, 'bundler/remote_specification'
20 autoload :Resolver, 'bundler/resolver'
c0f8641 Persist spec groups to the lockfile
Carl Lerche authored
21 autoload :Runtime, 'bundler/runtime'
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
22 autoload :Settings, 'bundler/settings'
f7bfdde Actually disable system gems in .bundle/environment.rb
Carlhuda authored
23 autoload :SharedHelpers, 'bundler/shared_helpers'
529d792 Use tsort to order specifications. It makes teh crazy work.
Carl Lerche authored
24 autoload :SpecSet, 'bundler/spec_set'
152a50a Rename gemfile back to bundler
Carl Lerche authored
25 autoload :Source, 'bundler/source'
0f97e4f @indirect Gems from git need their full_gem_path fixed, even when locked
indirect authored
26 autoload :Specification, 'bundler/shared_helpers'
434fb42 First pass at output
Carlhuda authored
27 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
28
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
29 class BundlerError < StandardError
30 def self.status_code(code = nil)
0ae574c DslError should inherit from Bundler::Error so its exceptions are cau…
Carlhuda authored
31 define_method(:status_code) { code }
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
32 end
33 end
34
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
35 class GemfileNotFound < BundlerError; status_code(10) ; end
36 class GemNotFound < BundlerError; status_code(7) ; end
37 class GemfileError < BundlerError; status_code(4) ; end
248ca34 Raise a better error in the case that a git repo is not cloned yet.
Carl Lerche authored
38 class PathError < BundlerError; status_code(13) ; end
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
39 class GitError < BundlerError; status_code(11) ; end
6a82ed0 @indirect Add GemspecError so it can be raised
indirect authored
40 class GemspecError < BundlerError; status_code(14) ; end
d7e1dc1 @wycats Remove standalone #git in the DSL. Instead, use the block form of #gi…
wycats authored
41 class DeprecatedError < BundlerError; status_code(12) ; end
2a24019 @indirect Print a useful error if a gemspec require fails
indirect authored
42 class GemspecError < BundlerError; status_code(14) ; end
0ae574c DslError should inherit from Bundler::Error so its exceptions are cau…
Carlhuda authored
43 class DslError < BundlerError; status_code(15) ; end
cb3ec8e Update --production to yell if the user changed their Gemfile without…
Carlhuda authored
44 class ProductionError < BundlerError; status_code(16) ; end
0ae574c DslError should inherit from Bundler::Error so its exceptions are cau…
Carlhuda authored
45 class InvalidOption < DslError ; end
67859e4 Moving in thor
Carlhuda authored
46
3edfddb Hacked together some crap that doesn't really work
Carl Lerche authored
47 class VersionConflict < BundlerError
48 attr_reader :conflicts
49
50 def initialize(conflicts, msg = nil)
51 super(msg)
52 @conflicts = conflicts
53 end
54
55 status_code(6)
56 end
57
cf736cf Use the Lockfile's specs as LazySpecifications instead of converting …
Carl Lerche authored
58 # Internal errors, should be rescued
59 class InvalidSpecSet < StandardError; end
60
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
61 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
62 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
63
64 def configure
65 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
66 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
67 true
68 end
69 end
434fb42 First pass at output
Carlhuda authored
70
cb3ec8e Update --production to yell if the user changed their Gemfile without…
Carlhuda authored
71 def production?
72 @production
73 end
74
75 def production=(value)
76 @production = value
77 end
78
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
79 def ui
80 @ui ||= UI.new
81 end
434fb42 First pass at output
Carlhuda authored
82
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
83 def bundle_path
5b2d02f Make bundle install [PATH] namespace its gems to specific rubies
Carlhuda authored
84 # STDERR.puts settings.path
85 @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
86 end
87
5f26a03 Have bundler generate executable stubs into ~/.bundler/bin that will …
Carl Lerche authored
88 def bin_path
89 @bin_path ||= begin
25ab2dc Make generating bin stubs an option
Carl Lerche authored
90 path = settings[:bin] || "bin"
91 path = Pathname.new(path).expand_path(root)
5f26a03 Have bundler generate executable stubs into ~/.bundler/bin that will …
Carl Lerche authored
92 FileUtils.mkdir_p(path)
93 Pathname.new(path).expand_path
94 end
95 end
96
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
97 def setup(*groups)
9cd1836 @lenary avoid warning: instance variable @setup not initialized
lenary authored
98 return @setup if defined?(@setup) && @setup
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
99
5dfc54c @indirect Don't call exit! if Bundler.setup has an exception
indirect authored
100 if groups.empty?
101 # Load all groups, but only once
102 @setup = load.setup
103 else
104 # Figure out which groups haven't been loaded yet
105 unloaded = groups - (@completed_groups || [])
106 # Record groups that are now loaded
107 @completed_groups = groups | (@completed_groups || [])
108 # Load any groups that are not yet loaded
109 unloaded.any? ? load.setup(*unloaded) : load
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
110 end
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
111 end
ce350cc Get a simple bbl install working
Carlhuda authored
112
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
113 def require(*groups)
69acfd8 @indirect Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
114 setup(*groups).require(*groups)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
115 end
116
625818a @indirect Clean up bundler.rb a bit
indirect authored
117 def load
91c74f4 Bundle.load and Bundle.runtime are the same thing again.
Carl Lerche authored
118 @load ||= Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
119 end
67859e4 Moving in thor
Carlhuda authored
120
3687843 @kevmoo check only needs Environment (not Runtime)
kevmoo authored
121 def environment
122 Bundler::Environment.new(root, definition)
123 end
124
8a4dc7a Remove a little bit of crazy from Definition
Carl Lerche authored
125 def definition(unlock = nil)
126 @definition = nil if unlock
2b9094e Scope specs in the lock file by source
Carl Lerche authored
127 @definition ||= begin
128 configure
e0e79df @indirect Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
129 upgrade_lockfile
2b9094e Scope specs in the lock file by source
Carl Lerche authored
130 lockfile = root.join("Gemfile.lock")
8a4dc7a Remove a little bit of crazy from Definition
Carl Lerche authored
131 Definition.build(default_gemfile, lockfile, unlock)
2b9094e Scope specs in the lock file by source
Carl Lerche authored
132 end
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from fle…
Carlhuda authored
133 end
134
eda7324 @wycats Git should never use sudo
wycats authored
135 def ruby_scope
136 "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
137 end
138
139 def user_bundle_path
140 Pathname.new(Gem.user_home).join(".bundler")
141 end
142
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
143 def home
625818a @indirect Clean up bundler.rb a bit
indirect authored
144 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
145 end
f31835e More work towards awesomeness
Carlhuda authored
146
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
147 def install_path
148 home.join("gems")
149 end
0d2492d Add more stuff for git
Carl Lerche authored
150
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
151 def specs_path
152 bundle_path.join("specifications")
153 end
154
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
155 def cache
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
156 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
157 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
158
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
159 def root
2d87c36 Move <root>/vendor/cache to a Bundler class method
Carl Lerche authored
160 default_gemfile.dirname.expand_path
161 end
162
163 def app_cache
164 root.join("vendor/cache")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
165 end
166
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
167 def tmp
eda7324 @wycats Git should never use sudo
wycats authored
168 user_bundle_path.join("tmp")
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
169 end
170
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
171 def settings
172 @settings ||= Settings.new(root)
173 end
174
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
175 def with_clean_env
176 bundled_env = ENV.to_hash
177 ENV.replace(ORIGINAL_ENV)
178 yield
179 ensure
180 ENV.replace(bundled_env.to_hash)
181 end
182
fb1e725 Make bundler/setup something you can add to your .profile. To do this…
Carlhuda authored
183 def default_gemfile
184 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
185 end
186
16259ea @wycats Improve sudo support
wycats authored
187 WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)!
188 NULL = WINDOWS ? "NUL" : "/dev/null"
189
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
190 def requires_sudo?
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
191 path = bundle_path
192 path = path.parent until path.exist?
52576d5 @spastorino requires_sudo if the path is not writable and sudo command exist
spastorino authored
193 sudo_present = !`which sudo 2>#{NULL}`.empty?
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
194
52576d5 @spastorino requires_sudo if the path is not writable and sudo command exist
spastorino authored
195 !File.writable?(path) && sudo_present
3f350e0 Add more sanity to the cases where bundler runs commands with sudo
Carlhuda authored
196 end
197
198 def mkdir_p(path)
199 if requires_sudo?
200 sudo "mkdir -p '#{path}'"
201 else
202 FileUtils.mkdir_p(path)
203 end
204 end
205
206 def sudo(str)
c5f25d6 Remove sudo -E, which never actually worked for what we wanted, and d…
Carlhuda authored
207 `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}`
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
208 end
209
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
210 private
211
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
212 def configure_gem_home_and_path
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
213 if settings[:disable_shared_gems]
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
214 ENV['GEM_PATH'] = ''
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
215 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
da1ba63 Don't set $GEM_HOME unless necessary
Carl Lerche authored
216 elsif Gem.dir != bundle_path.to_s
7a7628c @indirect Don't duplicate gem paths
indirect authored
217 paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
55509f2 @indirect Ignore paths like GEM_HOME that are empty strings
indirect authored
218 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
219 ENV["GEM_HOME"] = bundle_path.to_s
220 end
221
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
222 Gem.clear_paths
223 end
e0e79df @indirect Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
224
225 def upgrade_lockfile
226 lockfile = root.join("Gemfile.lock")
227 if lockfile.exist? && lockfile.read(3) == "---"
91c3beb @indirect Back to deleting old lockfiles for the beta release
indirect authored
228 Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
229 lockfile.rmtree
230 # lock = YAML.load_file(lockfile)
231 #
232 # source_uris = lock["sources"].map{|s| s["Rubygems"]["uri"] }
233 # sources = [Bundler::Source::Rubygems.new({"remotes" => source_uris})]
234 #
235 # deps = lock["dependencies"].map do |name, opts|
236 # version = opts.delete("version")
237 # Bundler::Dependency.new(name, version, opts)
238 # end
239 #
240 # definition = Bundler::Definition.new(nil, deps, sources, {})
241 #
242 # File.open(lockfile, 'w') do |f|
243 # f.write definition.to_lock
244 # end
e0e79df @indirect Upgrade 0.9 lockfiles to 1.0 lockfiles in-place
indirect authored
245 end
246 end
247
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
248 end
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
249 end
Something went wrong with that request. Please try again.