Class: Gemvault::CLI::Commands::Doctor

Inherits:
Gemvault::CLI::Command show all
Defined in:
lib/gemvault/cli/commands/doctor.rb

Overview

Recovers from wrecked bundler plugin state. Two wrecks are repaired:

A bundler plugin index entry whose stored path no longer exists. Bundler records absolute paths in .bundle/plugin/index for path-installed plugins. Moving or renaming the source directory leaves an invalid path behind -- Bundler::Plugin.load_plugin warns "The following plugin paths don't exist: ..." and silently returns, leaving @sources nil. The next source X, type: :vault crashes inside Bundler::SourceList#add_plugin_source with NoMethodError on nil. Uninstalling clears the broken entry.

A ghost specification: an installation record whose gem directory is gone (see Gemvault::GhostSpecification). Bundler's plugin installer trusts the record and validates plugins.rb against the missing directory instead of the copy it just installed, so every bundle install fails with MalformattedPlugin (issue #23). Removing the record lets the reinstall see the machine as it is.

Re-running bundle install afterwards triggers Bundler to reinstall the plugin against whatever the current Gemfile declares. Run this from the project directory.

Constant Summary collapse

OWNED_GEMS =
%w[gemvault bundler-source-vault].freeze
PERMISSION_HINT =
"(re-run with permissions for that gem home, e.g. sudo gemvault doctor)".freeze

Instance Method Summary collapse

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/gemvault/cli/commands/doctor.rb', line 35

def run
  begin
    remove_ghost_specifications
  rescue SystemCallError => e
    print_error("#{e.message} #{PERMISSION_HINT}")
    exit(1)
  end
  system("bundle", "plugin", "uninstall", "bundler-source-vault", exception: true)
  exec("bundle", "install")
end