Class: Homebrew::Cmd::RbenvSync Private

Inherits:
AbstractCommand show all
Defined in:
cmd/rbenv-sync.rb,
sorbet/rbi/dsl/homebrew/cmd/rbenv_sync.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::Cmd::RbenvSync::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/cmd/rbenv_sync.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'cmd/rbenv-sync.rb', line 22

def run
  rbenv_root = Pathname(ENV.fetch("HOMEBREW_RBENV_ROOT", Pathname(Dir.home)/".rbenv"))

  # Don't run multiple times at once.
  rbenv_sync_running = rbenv_root/".rbenv_sync_running"
  return if rbenv_sync_running.exist?

  begin
    rbenv_versions = rbenv_root/"versions"
    rbenv_versions.mkpath
    FileUtils.touch rbenv_sync_running

    HOMEBREW_CELLAR.glob("ruby{,@*}")
                   .flat_map(&:children)
                   .each { |path| link_rbenv_versions(path, rbenv_versions) }

    rbenv_versions.children
                  .select(&:symlink?)
                  .reject(&:exist?)
                  .each { |path| FileUtils.rm_f path }
  ensure
    rbenv_sync_running.unlink if rbenv_sync_running.exist?
  end
end