    # File lib/rubygems/commands/update_command.rb, line 106
      def do_rubygems_update(version)
        args = []
        args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
        args << '--no-rdoc' unless options[:generate_rdoc]
        args << '--no-ri' unless options[:generate_ri]
        args << '--no-format-executable' if options[:no_format_executable]

        update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"

        success = false

        Dir.chdir update_dir do
          say "Installing RubyGems #{version}"
          setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"

          # Make sure old rubygems isn't loaded
          old = ENV["RUBYOPT"]
          ENV.delete("RUBYOPT")
          system setup_cmd
          ENV["RUBYOPT"] = old if old
        end
      end