In Files

  • rubygems/doctor.rb


Included Modules

Class/Module Index [+]



Cleans up after a partially-failed uninstall or for an invalid Gem::Specification.

If a specification was removed by hand this will remove any remaining files.

If a corrupt specification was installed this will clean up warnings by removing the bogus specification.

Public Class Methods

new(gem_repository, dry_run = false) click to toggle source

Creates a new Gem::Doctor that will clean up gem_repository. Only one gem repository may be cleaned at a time.

If dry_run is true no files or directories will be removed.

               # File rubygems/doctor.rb, line 43
def initialize gem_repository, dry_run = false
  @gem_repository = gem_repository
  @dry_run        = dry_run

  @installed_specs = nil

Public Instance Methods

doctor() click to toggle source

Cleans up uninstalled files and invalid gem specifications

               # File rubygems/doctor.rb, line 67
def doctor
  @orig_home = Gem.dir
  @orig_path = Gem.path

  say "Checking #{@gem_repository}"

  Gem.use_paths @gem_repository.to_s

  unless gem_repository? then
    say 'This directory does not appear to be a RubyGems repository, ' +


  Gem.use_paths @orig_home, *@orig_path
gem_repository?() click to toggle source

Are we doctoring a gem repository?

               # File rubygems/doctor.rb, line 60
def gem_repository?
  not installed_specs.empty?

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit