Class Index [+]

Quicksearch

Bundler

Some versions of the Bundler 1.1 RC series introduced corrupted lockfiles. There were two major problems:

As a result, Bundler 1.1 contains code that fixes the earlier corruption. We will remove this fix-up code in Bundler 1.2.

Constants

ORIGINAL_ENV
WINDOWS
FREEBSD
NULL
VERSION

We’re doing this because we might write tests that deal with other versions of bundler and we are unsure how to handle this better.

Attributes

ui[W]
bundle_path[W]
rubygems[R]

Public Class Methods

app_cache() click to toggle source
     # File lib/bundler.rb, line 173
173:     def app_cache
174:       root.join("vendor/cache")
175:     end
app_config_path() click to toggle source
     # File lib/bundler.rb, line 167
167:     def app_config_path
168:       ENV['BUNDLE_APP_CONFIG'] ?
169:         Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) :
170:         root.join('.bundle')
171:     end
bin_path() click to toggle source
    # File lib/bundler.rb, line 92
92:     def bin_path
93:       @bin_path ||= begin
94:         path = settings[:bin] || "bin"
95:         path = Pathname.new(path).expand_path(root)
96:         FileUtils.mkdir_p(path)
97:         Pathname.new(path).expand_path
98:       end
99:     end
bundle_path() click to toggle source
    # File lib/bundler.rb, line 88
88:     def bundle_path
89:       @bundle_path ||= Pathname.new(settings.path).expand_path(root)
90:     end
cache() click to toggle source
     # File lib/bundler.rb, line 159
159:     def cache
160:       bundle_path.join("cache/bundler")
161:     end
clean_exec(*args) click to toggle source
     # File lib/bundler.rb, line 208
208:     def clean_exec(*args)
209:       with_clean_env { Kernel.exec(*args) }
210:     end
clean_system(*args) click to toggle source
     # File lib/bundler.rb, line 204
204:     def clean_system(*args)
205:       with_clean_env { Kernel.system(*args) }
206:     end
configure() click to toggle source
    # File lib/bundler.rb, line 80
80:     def configure
81:       @configured ||= configure_gem_home_and_path
82:     end
default_gemfile() click to toggle source
     # File lib/bundler.rb, line 212
212:     def default_gemfile
213:       SharedHelpers.default_gemfile
214:     end
default_lockfile() click to toggle source
     # File lib/bundler.rb, line 216
216:     def default_lockfile
217:       SharedHelpers.default_lockfile
218:     end
definition(unlock = nil) click to toggle source
     # File lib/bundler.rb, line 130
130:     def definition(unlock = nil)
131:       @definition = nil if unlock
132:       @definition ||= begin
133:         configure
134:         upgrade_lockfile
135:         Definition.build(default_gemfile, default_lockfile, unlock)
136:       end
137:     end
environment() click to toggle source
     # File lib/bundler.rb, line 126
126:     def environment
127:       Bundler::Environment.new(root, definition)
128:     end
home() click to toggle source
     # File lib/bundler.rb, line 147
147:     def home
148:       bundle_path.join("bundler")
149:     end
install_path() click to toggle source
     # File lib/bundler.rb, line 151
151:     def install_path
152:       home.join("gems")
153:     end
load() click to toggle source
     # File lib/bundler.rb, line 122
122:     def load
123:       @load ||= Runtime.new(root, definition)
124:     end
load_gemspec(file) click to toggle source
     # File lib/bundler.rb, line 270
270:     def load_gemspec(file)
271:       path = Pathname.new(file)
272:       # Eval the gemspec from its parent directory
273:       Dir.chdir(path.dirname.to_s) do
274:         contents = File.read(path.basename.to_s)
275:         begin
276:           Gem::Specification.from_yaml(contents)
277:           # Raises ArgumentError if the file is not valid YAML
278:         rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
279:           begin
280:             eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
281:           rescue LoadError => e
282:             original_line = e.backtrace.find { |line| line.include?(path.to_s) }
283:             msg  = "There was a LoadError while evaluating #{path.basename}:\n  #{e.message}"
284:             msg << " from\n  #{original_line}" if original_line
285:             msg << "\n"
286: 
287:             if RUBY_VERSION >= "1.9"
288:               msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9."
289:             end
290: 
291:             raise GemspecError, msg
292:           end
293:         end
294:       end
295:     end
mkdir_p(path) click to toggle source
     # File lib/bundler.rb, line 243
243:     def mkdir_p(path)
244:       if requires_sudo?
245:         sudo "mkdir -p '#{path}'" unless File.exist?(path)
246:       else
247:         FileUtils.mkdir_p(path)
248:       end
249:     end
read_file(file) click to toggle source
     # File lib/bundler.rb, line 266
266:     def read_file(file)
267:       File.open(file, "rb") { |f| f.read }
268:     end
require(*groups) click to toggle source
     # File lib/bundler.rb, line 118
118:     def require(*groups)
119:       setup(*groups).require(*groups)
120:     end
requires_sudo?() click to toggle source
     # File lib/bundler.rb, line 229
229:     def requires_sudo?
230:       return @requires_sudo if defined?(@checked_for_sudo)
231: 
232:       path = bundle_path
233:       path = path.parent until path.exist?
234:       sudo_present = which "sudo"
235:       bin_dir = Pathname.new(Bundler.system_bindir)
236:       bin_dir = bin_dir.parent until bin_dir.exist?
237: 
238:       @checked_for_sudo = true
239:       sudo_gems = !File.writable?(path) || !File.writable?(bin_dir)
240:       @requires_sudo = settings.allow_sudo? && sudo_gems && sudo_present
241:     end
root() click to toggle source
     # File lib/bundler.rb, line 163
163:     def root
164:       default_gemfile.dirname.expand_path
165:     end
ruby_scope() click to toggle source
     # File lib/bundler.rb, line 139
139:     def ruby_scope
140:       "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
141:     end
settings() click to toggle source
     # File lib/bundler.rb, line 181
181:     def settings
182:       @settings ||= Settings.new(app_config_path)
183:     end
setup(*groups) click to toggle source
     # File lib/bundler.rb, line 101
101:     def setup(*groups)
102:       # Just return if all groups are already loaded
103:       return @setup if defined?(@setup)
104: 
105:       if groups.empty?
106:         # Load all groups, but only once
107:         @setup = load.setup
108:       else
109:         @completed_groups ||= []
110:         # Figure out which groups haven't been loaded yet
111:         unloaded = groups - @completed_groups
112:         # Record groups that are now loaded
113:         @completed_groups = groups
114:         unloaded.any? ? load.setup(*groups) : load
115:       end
116:     end
specs_path() click to toggle source
     # File lib/bundler.rb, line 155
155:     def specs_path
156:       bundle_path.join("specifications")
157:     end
sudo(str) click to toggle source
     # File lib/bundler.rb, line 262
262:     def sudo(str)
263:       `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}`
264:     end
system_bindir() click to toggle source
     # File lib/bundler.rb, line 220
220:     def system_bindir
221:       # Gem.bindir doesn't always return the location that Rubygems will install
222:       # system binaries. If you put '-n foo' in your .gemrc, Rubygems will
223:       # install binstubs there instead. Unfortunately, Rubygems doesn't expose
224:       # that directory at all, so rather than parse .gemrc ourselves, we allow
225:       # the directory to be set as well, via `bundle config bindir foo`.
226:       Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
227:     end
tmp() click to toggle source
     # File lib/bundler.rb, line 177
177:     def tmp
178:       user_bundle_path.join("tmp", Process.pid.to_s)
179:     end
ui() click to toggle source
    # File lib/bundler.rb, line 84
84:     def ui
85:       @ui ||= UI.new
86:     end
user_bundle_path() click to toggle source
     # File lib/bundler.rb, line 143
143:     def user_bundle_path
144:       Pathname.new(Bundler.rubygems.user_home).join(".bundler")
145:     end
which(executable) click to toggle source
     # File lib/bundler.rb, line 251
251:     def which(executable)
252:       if File.executable?(executable)
253:         executable
254:       else
255:         path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p|
256:           File.executable?(File.join(p, executable))
257:         end
258:         path && File.expand_path(executable, path)
259:       end
260:     end
with_clean_env() click to toggle source
     # File lib/bundler.rb, line 193
193:     def with_clean_env
194:       with_original_env do
195:         ENV.delete_if { |k,_| k[0,7] == 'BUNDLE_' }
196:         if ENV.has_key? 'RUBYOPT'
197:           ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
198:           ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
199:         end
200:         yield
201:       end
202:     end
with_original_env() click to toggle source
     # File lib/bundler.rb, line 185
185:     def with_original_env
186:       bundled_env = ENV.to_hash
187:       ENV.replace(ORIGINAL_ENV)
188:       yield
189:     ensure
190:       ENV.replace(bundled_env.to_hash)
191:     end

Private Class Methods

configure_gem_home() click to toggle source
     # File lib/bundler.rb, line 316
316:     def configure_gem_home
317:       # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
318:       FileUtils.mkdir_p bundle_path.to_s rescue nil
319: 
320:       ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
321:       Bundler.rubygems.clear_paths
322:     end
configure_gem_home_and_path() click to toggle source
     # File lib/bundler.rb, line 299
299:     def configure_gem_home_and_path
300:       blank_home = ENV['GEM_HOME'].nil? || ENV['GEM_HOME'].empty?
301: 
302:       if settings[:disable_shared_gems]
303:         ENV['GEM_PATH'] = ''
304:         configure_gem_home
305:       elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s
306:         possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
307:         paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
308:         ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
309:         configure_gem_home
310:       end
311: 
312:       Bundler.rubygems.refresh
313:       bundle_path
314:     end
upgrade_lockfile() click to toggle source
     # File lib/bundler.rb, line 324
324:     def upgrade_lockfile
325:       lockfile = default_lockfile
326:       if lockfile.exist? && lockfile.read(3) == "---"
327:         Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
328:         lockfile.rmtree
329:       end
330:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.