Skip to content
On this page

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

module · Ruby 3.4

Gem

110 class methods

RubyGems is the Ruby standard for publishing and managing third party libraries.

For user documentation, see:

For gem developer documentation see:

Further RubyGems documentation can be found at:

RubyGems Plugins

RubyGems will load plugins in the latest version of each installed gem or $LOAD_PATH. Plugins must be named ‘rubygems_plugin’ (.rb, .so, etc) and placed at the root of your gem’s require_path. Plugins are installed at a special location and loaded on boot.

For an example plugin, see the Graph gem which adds a gem graph command.

RubyGems Defaults, Packaging

RubyGems defaults are stored in lib/rubygems/defaults.rb. If you’re packaging RubyGems or implementing Ruby you can change RubyGems’ defaults.

For RubyGems packagers, provide lib/rubygems/defaults/operating_system.rb and override any defaults from lib/rubygems/defaults.rb.

For Ruby implementers, provide lib/rubygems/defaults/#{RUBY_ENGINE}.rb and override any defaults from lib/rubygems/defaults.rb.

If you need RubyGems to perform extra work on install or uninstall, your defaults override file can set pre/post install and uninstall hooks. See Gem::pre_install, Gem::pre_uninstall, Gem::post_install, Gem::post_uninstall.

Bugs

You can submit bugs to the RubyGems bug tracker on GitHub

Credits

RubyGems is currently maintained by Eric Hodel.

RubyGems was originally developed at RubyConf 2003 by:

  • Rich Kilmer – rich(at)infoether.com

  • Chad Fowler – chad(at)chadfowler.com

  • David Black – dblack(at)wobblini.net

  • Paul Brannan – paul(at)atdesk.com

  • Jim Weirich – jim(at)weirichhouse.org

Contributors:

  • Gavin Sinclair – gsinclair(at)soyabean.com.au

  • George Marrows – george.marrows(at)ntlworld.com

  • Dick Davies – rasputnik(at)hellooperator.net

  • Mauricio Fernandez – batsman.geo(at)yahoo.com

  • Simon Strandgaard – neoneye(at)adslhome.dk

  • Dave Glasser – glasser(at)mit.edu

  • Paul Duncan – pabs(at)pablotron.org

  • Ville Aine – vaine(at)cs.helsinki.fi

  • Eric Hodel – drbrain(at)segment7.net

  • Daniel Berger – djberg96(at)gmail.com

  • Phil Hagelberg – technomancy(at)gmail.com

  • Ryan Davis – ryand-ruby(at)zenspider.com

  • Evan Phoenix – evan(at)fallingsnow.net

  • Steve Klabnik – steve(at)steveklabnik.com

(If your name is missing, PLEASE let us know!)

License

See LICENSE.txt for permissions.

Thanks!

-The RubyGems Team

Provides 3 methods for declaring when something is going away.

+deprecate(name, repl, year, month)+:

Indicate something may be removed on/after a certain date.

+rubygems_deprecate(name, replacement=:none)+:

Indicate something will be removed in the next major RubyGems version,
and (optionally) a replacement for it.

rubygems_deprecate_command:

Indicate a RubyGems command (in +lib/rubygems/commands/*.rb+) will be
removed in the next RubyGems version.

Also provides skip_during for temporarily turning off deprecation warnings. This is intended to be used in the test suite, so deprecation warnings don’t cause test failures if you need to make sure stderr is otherwise empty.

Example usage of deprecate and rubygems_deprecate:

Example
class Legacy
  def self.some_class_method
    # ...
  end

  def some_instance_method
    # ...
  end

  def some_old_method
    # ...
  end

  extend Gem::Deprecate
  deprecate :some_instance_method, "X.z", 2011, 4
  rubygems_deprecate :some_old_method, "Modern#some_new_method"

  class << self
    extend Gem::Deprecate
    deprecate :some_class_method, :none, 2011, 4
  end
end

Example usage of rubygems_deprecate_command:

Example
class Gem::Commands::QueryCommand < Gem::Command
  extend Gem::Deprecate
  rubygems_deprecate_command

  # ...
end

Example usage of skip_during:

Example
class TestSomething < Gem::Testcase
  def test_some_thing_with_deprecations
    Gem::Deprecate.skip_during do
      actual_stdout, actual_stderr = capture_output do
        Gem.something_deprecated
      end
      assert_empty actual_stdout
      assert_equal(expected, actual_stderr)
    end
  end
end

Class methods 110

.activated_gem_paths .add_to_load_path .already_loaded? .binary_mode .bindir .bin_path .cache_home .clear_default_specs .clear_paths .config_file .config_home .configuration .configuration= .data_home .default_bindir .default_cert_path .default_dir .default_exec_format .default_ext_dir_for .default_gem_load_paths .default_key_path .default_path .default_rubygems_dirs .default_sources .default_spec_cache_dir .default_specifications_dir .deflate .dir .done_installing .dynamic_library_suffixes .ensure_default_gem_subdirectories .ensure_gem_subdirectories .env_requirement .find_config_file .find_default_spec .find_files .find_home .find_latest_files .find_spec_for_exe .find_unresolved_default_spec .finish_resolve .freebsd_platform? .host .host= .install .java_platform? .latest_rubygems_version .latest_spec_for .latest_version_for .load_env_plugins .load_path_insert_index .load_plugins .load_safe_marshal .load_yaml .location_of_caller .marshal_version .needs .open_file .open_file_with_flock .open_file_with_lock .operating_system_defaults .path .paths .paths= .path_separator .platform_defaults .platforms .platforms= .plugindir .plugin_suffix_pattern .plugin_suffix_regexp .post_build .post_install .post_reset .post_uninstall .prefix .pre_install .pre_reset .pre_uninstall .rdoc_hooks_defined_via_plugin? .read_binary .refresh .register_default_spec .ruby .ruby_api_version .ruby_engine .rubygems_version .ruby_version .set_target_rbconfig .solaris_platform? .source_date_epoch .source_date_epoch_string .sources .sources= .spec_cache_dir .state_file .state_home .suffixes .suffix_pattern .suffix_regexp .target_rbconfig .time .try_activate .ui .use_gemdeps .use_paths .user_dir .user_home .win_platform? .write_binary
Constants
No documentation available
No documentation available
No documentation available
No documentation available

Location of Marshal quick gemspecs on remote repositories

No documentation available

Subdirectories in a gem repository for default gems

Subdirectories in a gem repository

No documentation available
No documentation available

An Array of Regexps that match windows Ruby platforms.

Attributes

RubyGems distributors (like operating system package managers) can disable RubyGems update by setting this to error message printed to end-users on gem update –system instead of actual update.

Whether RubyGems should enhance builtin require to automatically check whether the path required is present in installed gems, and automatically activate them and add them to ‘$LOAD_PATH`.

The list of hooks to be run after Gem::DependencyInstaller installs a set of gems

Read

GemDependencyAPI object, which is set when .use_gemdeps is called. This contains all the information from the Gemfile.

Hash of loaded Gem::Specification keyed by name

The list of hooks to be run after Gem::Installer#install extracts files and builds extensions

The list of hooks to be run after Gem::Installer#install completes installation

The list of hooks to be run after Gem::Specification.reset is run.

The list of hooks to be run after Gem::Uninstaller#uninstall completes installation

The list of hooks to be run before Gem::Installer#install does any work

The list of hooks to be run before Gem::Specification.reset is run.

The list of hooks to be run before Gem::Uninstaller#uninstall does any work