meta_package_manager.managers.gem module¶
- class meta_package_manager.managers.gem.Gem[source]¶
Bases:
PackageManagerThe RubyGems package manager.
gem emits no machine-readable format, so installed, outdated and search listings are parsed from its text output. A gem can keep several versions installed side by side (
molinillo (0.5.4, 0.4.5, 0.2.3)); mpm reports the highest as the installed version.Note
All operations target the default gem scope (controlled by
GEM_HOME). On system Ruby this means system-level gems, which may require elevated privileges for write operations: those carry dormant privileged markers, sompm --sudoor a[mpm.managers.gem] sudo = trueoverride escalates them, while nothing escalates by default. On recent macOS that default scope lives on the sealed, read-only system volume, so the gems Ruby bundles there surface as outdated yet cannot be upgraded in place, not even withsudo: point mpm at a writable, user-controlled Ruby earlier on yourPATHinstead. Per-scope targeting (system vs user gems) is tracked in #1725.Tip
Installs require
sudoon system ruby. I (@tresni) recommend doing something like:$ sudo dseditgroup -o edit -a -t user wheel
And then do
visudoto make it so thewheelgroup does not require a password. There is a line already there for it, you just need to uncomment it and save.Initialize
cli_errorslist.- name: str = 'RubyGems'¶
Return package manager’s common name.
Default value is based on class name.
- homepage_url: str | None = 'https://rubygems.org'¶
Home page of the project, only used in documentation for reference.
- logo: str | None = 'rubygems'¶
Slug of the brand mark standing for this manager in the documentation.
Names an SVG vendored under
docs/assets/managers/, whose provenance and license are recorded indocs/assets/managers/logos.yaml. Inlined at the top of the manager’s page bymeta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.Several managers legitimately share one slug, either because they wrap the same upstream (
brewandcask) or because the tool has no mark of its own and its ecosystem’s stands in (aptunder Debian’s swirl,cargounder Rust’s gear). Documentation-only, likehomepage_url: no CLI output reads it.
- platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='aix', name='IBM AIX'), Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='cygwin', name='Cygwin'), Platform(id='debian', name='Debian'), Platform(id='dragonfly_bsd', name='DragonFly BSD'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='freebsd', name='FreeBSD'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='haiku', name='Haiku'), Platform(id='hurd', name='GNU/Hurd'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='illumos', name='illumos'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='macos', name='macOS'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='midnightbsd', name='MidnightBSD'), Platform(id='netbsd', name='NetBSD'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='openbsd', name='OpenBSD'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='os400', name='IBM i'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='solaris', name='Solaris'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='sunos', name='SunOS'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='windows', name='Windows'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})¶
List of platforms supported by the manager.
Allows for a mishmash of platforms and groups of platforms. Will be normalized into a
frozensetofPlatforminstances at instantiation.
- post_args: tuple[str, ...] = ('--quiet',)¶
Global list of options used before and after the invoked package manager CLI.
Automatically added to each
meta_package_manager.execution.CLIExecutor.run_cli()call.Essentially used to force silencing, low verbosity or no-color output.
- property installed: Iterator[Package]¶
Fetch installed packages.
$ gem list --quiet bigdecimal (default: 1.4.1) bundler (default: 1.17.2) CFPropertyList (2.3.6) cmath (default: 1.0.0) csv (default: 3.0.9) date (default: 2.0.0) fileutils (1.4.1, default: 1.1.0) io-console (0.5.6, default: 0.4.7) ipaddr (default: 1.2.2) molinillo (0.5.4, 0.4.5, 0.2.3) nokogiri (1.5.6) psych (2.0.0) rake (0.9.6) rdoc (4.0.0) sqlite3 (1.3.7) test-unit (2.0.0.0)
- property outdated: Iterator[Package]¶
Fetch outdated packages.
$ gem outdated --quiet did_you_mean (1.0.0 < 1.0.2) io-console (0.4.5 < 0.4.6) json (1.8.3 < 2.0.1) minitest (5.8.3 < 5.9.0) power_assert (0.2.6 < 0.3.0) psych (2.0.17 < 2.1.0)
- search(query, extended, exact)[source]¶
Fetch matching packages.
Caution
Search does not supports extended mode.
$ gem search python --versions --quiet at_coder_friends-generator-python_ref (0.2.0) bee_python (0.2.3) dependabot-python (0.117.5) logstash-filter-python (0.0.1 java) python (0.0.1) python-generator (1.1.0) python_with_git_test (2.499.8) rabbit-slide-niku-erlangvm-for-pythonista (2015.09.12) RubyToPython (0.0)
$ gem search python --versions --exact --quiet python (0.0.1)
- install(package_id, version=None)[source]¶
Install one package.
$ gem install --quiet markdown Fetching kramdown-2.3.1.gem Fetching concurrent-ruby-1.1.9.gem (...) Fetching rubyzip-2.3.2.gem Fetching logutils-0.6.1.gem Fetching markdown-1.2.0.gem Successfully installed kramdown-2.3.1 Successfully installed rubyzip-2.3.2 (...) Successfully installed markdown-1.2.0 (...) Parsing documentation for markdown-1.2.0 Installing ri documentation for markdown-1.2.0 Done installing documentation for (...) markdown after 19 seconds 12 gems installed
- Return type:
- upgrade_all_cli()[source]¶
Generates the CLI to upgrade all outdated packages.
$ gem update --quiet
- upgrade_one_cli(package_id, version=None)[source]¶
Generates the CLI to upgrade the provided package.
$ gem update --quiet markdown
- remove(package_id)[source]¶
Remove one package.
$ gem uninstall left-pad --quiet Successfully uninstalled left-pad-1.1.0
- Return type:
- cleanup_cache()[source]¶
Removes things we don’t need anymore.
$ gem cleanup --quiet Cleaning up installed gems... Attempting to uninstall test-unit-3.2.9 Unable to uninstall test-unit-3.2.9: Gem::FilePermissionError: You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory. Attempting to uninstall did_you_mean-1.3.0 Unable to uninstall did_you_mean-1.3.0: Gem::FilePermissionError: You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory. Clean up complete
- Return type:
- cli_names: tuple[str, ...] = ('gem',)¶
List of CLI names the package manager is known as.
This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.
- ..hint::
This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named
pythonorpython3.
By default, this property’s value is derived from the manager’s ID (see the
MetaPackageManager.__init__method above).
- doctor_cli()[source]¶
Generates the CLI running the native self-diagnosis.
checkverifies the integrity of every installed gem, exiting non-zero on problems.$ gem check --quiet