Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 193 lines (163 sloc) 5.109 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'
54cc01d First pass at generating the new Lockfile
Carlhuda authored
14 autoload :Flex, 'bundler/flex'
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'
152a50a Rename gemfile back to bundler
Carl Lerche authored
18 autoload :RemoteSpecification, 'bundler/remote_specification'
19 autoload :Resolver, 'bundler/resolver'
c0f8641 Persist spec groups to the lockfile
Carl Lerche authored
20 autoload :Runtime, 'bundler/runtime'
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
21 autoload :Settings, 'bundler/settings'
f7bfdde Actually disable system gems in .bundle/environment.rb
Carlhuda authored
22 autoload :SharedHelpers, 'bundler/shared_helpers'
529d792 Use tsort to order specifications. It makes teh crazy work.
Carl Lerche authored
23 autoload :SpecSet, 'bundler/spec_set'
152a50a Rename gemfile back to bundler
Carl Lerche authored
24 autoload :Source, 'bundler/source'
0f97e4f @indirect Gems from git need their full_gem_path fixed, even when locked
indirect authored
25 autoload :Specification, 'bundler/shared_helpers'
434fb42 First pass at output
Carlhuda authored
26 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
27
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
28 class BundlerError < StandardError
29 def self.status_code(code = nil)
30 return @code unless code
31 @code = code
32 end
33
34 def status_code
35 self.class.status_code
36 end
37 end
38
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
39 class GemfileNotFound < BundlerError; status_code(10) ; end
40 class GemNotFound < BundlerError; status_code(7) ; end
41 class VersionConflict < BundlerError; status_code(6) ; end
42 class GemfileError < BundlerError; status_code(4) ; end
ef6a00f @indirect Print better error during install when you need to relock
indirect authored
43 class GemfileChanged < GemfileError; status_code(4) ; end
248ca34 Raise a better error in the case that a git repo is not cloned yet.
Carl Lerche authored
44 class PathError < BundlerError; status_code(13) ; end
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
45 class GitError < BundlerError; status_code(11) ; end
46 class DeprecatedMethod < BundlerError; status_code(12) ; end
47 class DeprecatedOption < BundlerError; status_code(12) ; end
2a24019 @indirect Print a useful error if a gemspec require fails
indirect authored
48 class GemspecError < BundlerError; status_code(14) ; end
7514b20 @wycats If an option is invalid, don't fail silently
wycats authored
49 class InvalidOption < BundlerError; status_code(15) ; end
67859e4 Moving in thor
Carlhuda authored
50
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
51 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
52 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
53
54 def configure
55 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
56 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
57 true
58 end
59 end
434fb42 First pass at output
Carlhuda authored
60
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
61 def ui
62 @ui ||= UI.new
63 end
434fb42 First pass at output
Carlhuda authored
64
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
65 def bundle_path
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
66 @bundle_path ||= begin
58b31d8 Namespace the default bundle path to support with the ruby engine and ve...
Carlhuda authored
67 path = settings[:path] || "#{Gem.user_home}/.bundle/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
68 Pathname.new(path).expand_path(root)
69 end
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
70 end
71
0753a24 @indirect Stop infinite recursion in locked bundles that include Bundler
indirect authored
72 def gem_setup(*groups)
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
73 return @setup if @setup
74
1f84fd9 @indirect Pretty error from Bundle.setup when gems are missing
indirect authored
75 begin
76 if groups.empty?
77 # Load all groups, but only once
78 @setup = load.setup
79 else
80 # Figure out which groups haven't been loaded yet
81 unloaded = groups - (@completed_groups || [])
82 # Record groups that are now loaded
83 @completed_groups = groups | (@completed_groups || [])
84 # Load any groups that are not yet loaded
85 unloaded.any? ? load.setup(*unloaded) : load
86 end
87 rescue Bundler::GemNotFound => e
88 STDERR.puts e.message
89 STDERR.puts "Try running `bundle install`."
90 exit!
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
91 end
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
92 end
0753a24 @indirect Stop infinite recursion in locked bundles that include Bundler
indirect authored
93 alias setup gem_setup unless Bundler.respond_to?(:setup)
ce350cc Get a simple bbl install working
Carlhuda authored
94
0753a24 @indirect Stop infinite recursion in locked bundles that include Bundler
indirect authored
95 def gem_require(*groups)
69acfd8 @indirect Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
96 setup(*groups).require(*groups)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
97 end
0753a24 @indirect Stop infinite recursion in locked bundles that include Bundler
indirect authored
98 alias require gem_require unless Bundler.respond_to?(:require)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
99
625818a @indirect Clean up bundler.rb a bit
indirect authored
100 def load
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
101 @load ||= begin
102 if current_env_file?
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
103 @gem_loaded = true
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
104 Kernel.require env_file
105 Bundler
106 else
107 runtime
108 end
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
109 end
110 end
111
112 def runtime
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
113 @runtime ||= Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
114 end
67859e4 Moving in thor
Carlhuda authored
115
625818a @indirect Clean up bundler.rb a bit
indirect authored
116 def definition
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
117 configure
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
118 lockfile = root.join("Gemfile.lock")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
119 if lockfile.exist?
120 Definition.from_lock(lockfile)
121 else
625818a @indirect Clean up bundler.rb a bit
indirect authored
122 Definition.from_gemfile(default_gemfile)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
123 end
88741e6 First pass at bbl lock
Carlhuda authored
124 end
f31835e More work towards awesomeness
Carlhuda authored
125
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from flex_i...
Carlhuda authored
126 # TODO: obvious
127 def flexdef
128 configure
129 lockfile = root.join("Gemfile.lock")
54cc01d First pass at generating the new Lockfile
Carlhuda authored
130 Flex::Definition.build(default_gemfile, lockfile)
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from flex_i...
Carlhuda authored
131 end
132
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
133 def home
625818a @indirect Clean up bundler.rb a bit
indirect authored
134 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
135 end
f31835e More work towards awesomeness
Carlhuda authored
136
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
137 def install_path
138 home.join("gems")
139 end
0d2492d Add more stuff for git
Carl Lerche authored
140
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
141 def specs_path
142 bundle_path.join("specifications")
143 end
144
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
145 def cache
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
146 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
147 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
148
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
149 def root
150 default_gemfile.dirname
151 end
152
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
153 def settings
154 @settings ||= Settings.new(root)
155 end
156
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
157 def env_file
158 SharedHelpers.env_file
159 end
160
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
161 def with_clean_env
162 bundled_env = ENV.to_hash
163 ENV.replace(ORIGINAL_ENV)
164 yield
165 ensure
166 ENV.replace(bundled_env.to_hash)
167 end
168
fb1e725 Make bundler/setup something you can add to your .profile. To do this, a...
Carlhuda authored
169 def default_gemfile
170 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
171 end
172
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
173 private
174
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
175 def configure_gem_home_and_path
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
176 if settings[:disable_shared_gems]
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
177 ENV['GEM_PATH'] = ''
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
178 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
179 else
7a7628c @indirect Don't duplicate gem paths
indirect authored
180 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
181 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
182 ENV["GEM_HOME"] = bundle_path.to_s
183 end
184
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
185 Gem.clear_paths
186 end
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
187
188 def current_env_file?
189 env_file.exist? && (env_file.read(100) =~ /Bundler #{Bundler::VERSION}/)
190 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
191 end
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
192 end
Something went wrong with that request. Please try again.