class Bundler::SelfManager
def restart_with(version)
def restart_with(version) configured_gem_home = ENV["GEM_HOME"] configured_gem_path = ENV["GEM_PATH"] # Bundler specs need some stuff to be required before Bundler starts # running, for example, for faking the compact index API. However, these # flags are lost when we reexec to a different version of Bundler. In the # future, we may be able to properly reconstruct the original Ruby # invocation (see https://bugs.ruby-lang.org/issues/6648), but for now # there's no way to do it, so we need to be explicit about how to re-exec. # This may be a feature end users request at some point, but maybe by that # time, we have builtin tools to do. So for now, we use an undocumented # ENV variable only for our specs. bundler_spec_original_cmd = ENV["BUNDLER_SPEC_ORIGINAL_CMD"] if bundler_spec_original_cmd require "shellwords" cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV] else argv0 = File.exist?($PROGRAM_NAME) ? $PROGRAM_NAME : Process.argv0 cmd = [argv0, *ARGV] cmd.unshift(Gem.ruby) unless File.executable?(argv0) end Bundler.with_original_env do Kernel.exec( { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s }, *cmd ) end end