install a particular gem
192514
def install_gem(gem):
    
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),
                  warn_only=False, capture=True):
        # convert 0 into True, any errors will always raise an exception
        return not bool(
            run("gem install %s --no-rdoc --no-ri" % gem).return_code)
1240502
def load_needed_dependencies!
      spec_version = WINRM_FS_SPEC_VERSION.dup
      logger.debug('winrm-fs requested,' \
        " loading WinRM::FS gem (#{spec_version})")
      gem 'winrm-fs', spec_version
      first_load = require 'winrm-fs'
      load_winrm_transport!

      if first_load
        logger.debug('WinRM::FS library loaded')
      else
        logger.debug('WinRM::FS previously loaded')
      end
    rescue LoadError => e
      logger.fatal(
        "The `winrm-fs' gem is missing and must" \
        ' be installed or cannot be properly activated. Run' \
        " `gem install winrm-fs --version '#{spec_version}'`" \
        ' or add the following to your Gemfile if you are using Bundler:' \
        " `gem 'winrm-fs', '#{spec_version}'`.",
      )
      raise Train::UserError,
            "Could not load or activate WinRM::FS (#{e.message})"
    end
1060387
def query_gems_list
      Utils.gems_collection(false) # load collection
      gems = Parallel.map(query_gems, in_threads: 4) do |query_gem|
        gem_dependencies(query_gem)
      end

      gems.flatten!
      gems.reject!(&:empty?)
      gems
    end
138593
def install_system_gem(gem):
    
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),
                  warn_only=False, capture=True):
        sudo("gem install %s --no-rdoc --no-ri" % gem)
1014569
def load_gems
      load_paths
      prospective_gems.each do |prospect|
        gem_name = prospect.dup
        begin
          loaded = @proxy.proxy(Kernel, :require, gem_name)
          # puts "Loading Gem: #{gem_name} => #{loaded}"
        rescue LoadError, NameError => e
          old_gem_name = gem_name.dup
          gem_name.gsub!('-', '/')
          retry if old_gem_name != gem_name
        end
      end
    end
553885
def add_or_update_gemfile(update_gemfile_if_needed: false)
      if gemfile_exists?
        ensure_gemfile_valid!(update_gemfile_if_needed: update_gemfile_if_needed)
      else
        if update_gemfile_if_needed || UI.confirm("It is recommended to run fastlane with a Gemfile set up, do you want fastlane to create one for you?")
          setup_gemfile!
        end
      end
      return gemfile_path
    end
658339
def init!(plugins, repair=false)
      if !@initial_specifications
        @initial_specifications = Gem::Specification.find_all{true}
      else
        Gem::Specification.all = @initial_specifications
        Gem::Specification.reset
      end

      # Add HashiCorp RubyGems source
      if !Gem.sources.include?(HASHICORP_GEMSTORE)
        current_sources = Gem.sources.sources.dup
        Gem.sources.clear
        Gem.sources << HASHICORP_GEMSTORE
        current_sources.each do |src|
          Gem.sources << src
        end
      end

      # Generate dependencies for all registered plugins
      plugin_deps = plugins.map do |name, info|
        Gem::Dependency.new(name, info['installed_gem_version'].to_s.empty? ? '> 0' : info['installed_gem_version'])
      end

      @logger.debug("Current generated plugin dependency list: #{plugin_deps}")

      # Load dependencies into a request set for resolution
      request_set = Gem::RequestSet.new(*plugin_deps)
      # Never allow dependencies to be remotely satisfied during init
      request_set.remote = false

      repair_result = nil
      begin
        # Compose set for resolution
        composed_set = generate_vagrant_set
        # Resolve the request set to ensure proper activation order
        solution = request_set.resolve(composed_set)
      rescue Gem::UnsatisfiableDependencyError => failure
        if repair
          raise failure if @init_retried
          @logger.debug("Resolution failed but attempting to repair. Failure: #{failure}")
          install(plugins)
          @init_retried = true
          retry
        else
          raise
        end
      end

      # Activate the gems
      activate_solution(solution)

      full_vagrant_spec_list = @initial_specifications +
        solution.map(&:full_spec)

      if(defined?(::Bundler))
        @logger.debug("Updating Bundler with full specification list")
        ::Bundler.rubygems.replace_entrypoints(full_vagrant_spec_list)
      end

      Gem.post_reset do
        Gem::Specification.all = full_vagrant_spec_list
      end

      Gem::Specification.reset
      nil
    end
729531
def run(self):
    """"""

    module = self.distribution.ext_modules[0]

    building_for_windows = self.plat_name in ['win32', 'win-amd64']
    if building_for_windows:
      module.define_macros.append(('_CRT_SECURE_NO_WARNINGS', '1'))
      module.libraries.append('advapi32')

    if self.dynamic_linking:
      module.libraries.append('yara')
    else:
      for source in yara_sources:
        module.sources.append(source)

    build_ext.build_ext.run(self)
10063
def add_versions
      new_gemfile = Tempfile.new("Gemfile.versioned")
      begin
        gemfile_content.each do |gem_line|
          if is_gem_line?(gem_line)
            new_gemfile.puts(build_gem_line(gem_line))
          else
            new_gemfile.puts(gem_line)
          end
        end
        File.truncate(gemfile_path, 0)
        new_gemfile.rewind
        File.open(gemfile_path, "w") {|f| f.write(new_gemfile.read)}
      rescue Exception => e
        puts "ERROR: #{e}"
        puts "Restoring Gemfile at #{gemfile_path}"
        File.open(gemfile_path, "w") {|f| f.write(@orig_gemfile)}
      ensure
        new_gemfile.close
        new_gemfile.unlink
      end
    end
401338
def parse_gemfile
      gemfile = File.join(Rails.root, 'Gemfile')
      @gem_lines = IO.readlines(gemfile).select{|line| line =~ /\A\s*gem/ }
    end
740886
def run(self):
        """"""
        install.run(self)

        #
        # Remove old pygubu.py from scripts path if exists
        spath = os.path.join(self.install_scripts, 'pygubu')
        for ext in ('.py', '.pyw'):
            filename = spath + ext
            if os.path.exists(filename):
                os.remove(filename)
        #
        # Remove old pygubu-designer.bat
        if platform.system() == 'Windows':
            spath = os.path.join(self.install_scripts, 'pygubu-designer.bat')
            if os.path.exists(spath):
                os.remove(spath)
1013340
def find_gem_name(base)
      spec = Dir[File.join(base, '*.gemspec')].first
      File.basename(spec, '.gemspec') if spec
    end
1129387
def available_gems
      return [] unless gemfile_path
      dsl = Bundler::Dsl.evaluate(gemfile_path, nil, true)
      return dsl.dependencies.map(&:name)
    end
1363118
function install(runtime, abi, platform, arch, cb) {
  const essential = runtime + '-v' + abi + '-' + platform + '-' + arch;
  const pkgVersion = pkg.version;
  const currentPlatform = pkg.name + '-v' + pkgVersion + '-' + essential;

  console.log('Downloading prebuild for platform:', currentPlatform);
  let downloadUrl = 'https://github.com/WilixLead/iohook/releases/download/v' + pkgVersion + '/' + currentPlatform + '.tar.gz';

  let reqOpts = {url: downloadUrl};
  let tempFile = path.join(os.tmpdir(), 'prebuild.tar.gz');
  let req = get(reqOpts, function(err, res) {
    if (err) {
      return onerror(err);
    }
    if (res.statusCode !== 200) {
      if (res.statusCode === 404) {
        console.error('Prebuild for current platform (' + currentPlatform + ') not found!');
        console.error('Try to compile for your platform:');
        console.error('# cd node_modules/iohook;');
        console.error('# npm run compile');
        console.error('');
        return onerror('Prebuild for current platform (' + currentPlatform + ') not found!');
      }
      return onerror('Bad response from prebuild server. Code: ' + res.statusCode);
    }
    pump(res, fs.createWriteStream(tempFile), function(err) {
      if (err) {
        throw err;
      }
      let options = {
        readable: true,
        writable: true,
        hardlinkAsFilesFallback: true
      };
      let binaryName;
      let updateName = function(entry) {
        if (/\.node$/i.test(entry.name)) binaryName = entry.name
      };
      let targetFile = path.join(__dirname, 'builds', essential);
      let extract = tfs.extract(targetFile, options)
        .on('entry', updateName);
      pump(fs.createReadStream(tempFile), zlib.createGunzip(), extract, function(err) {
        if (err) {
          return onerror(err);
        }
        cb()
      })
    })
  });

  req.setTimeout(30 * 1000, function() {
    req.abort()
  })
}
1288199
def choose_best_gem
      gems_to_try = []
      #puts "Ruby MAJOR: #{Rest.ruby_major}"
      if Rest.ruby_major >= 2
        gems_to_try << :net_http_persistent
        gems_to_try << :typhoeus
        gems_to_try << :rest_client
        gems_to_try << :internal
      else
        # net-http-persistent has issues with ssl and keep-alive connections on ruby < 1.9.3p327
        gems_to_try << :typhoeus
        gems_to_try << :rest_client
        gems_to_try << :internal
      end
      gems_to_try.each_with_index do |g, i|
        bg = Rest.backing_gems[g]
        begin
          require bg.gem_name unless g == :internal
          @gem = bg.name
          return @gem
        rescue LoadError => ex
          if (i+1) >= gems_to_try.length
            raise ex
          end
          @logger.debug "LoadError on #{bg.name}, trying #{Rest.backing_gems[gems_to_try[i+1]].name}..."
        end
      end
    end
665413
def gemspec
      @gemspec ||= begin
        raise Error.new("Unable to automatically determine gem name from specs in #{base}. Please set the gem name via #{self.class.name}.install_tasks(gem_name: 'name')") unless gem_name
        g = Bundler.load_gemspec(File.join(base, gem_name+'.gemspec'))
        # This is returning the path it would be in if installed normally,
        # override so we get the local path. Also for reasons that are entirely
        # beyond me, #tap makes Gem::Specification flip out so do it old-school.
        g.full_gem_path = base
        g
      end
    end
1367777
def install(
    board_id='atmega88',
    mcu='atmega88',
    f_cpu=20000000,
    upload='usbasp',
    core='arduino',
    replace_existing=True,
):
    """"""

    board = AutoBunch()
    board.name = TEMPL.format(mcu=mcu, f_cpu=f_cpu, upload=upload)

    board.upload.using = upload
    board.upload.maximum_size = 8 * 1024

    board.build.mcu = mcu
    board.build.f_cpu = str(f_cpu) + 'L'
    board.build.core = core

    # for 1.0
    board.build.variant = 'standard'

    install_board(board_id, board, replace_existing=replace_existing)