* gem - fix --user-install conflict with OS-injected --install-dir
Some distributions (e.g. Fedora) inject --install-dir via operating_system.rb
as a platform default. Combining that with --user-install causes a gem CLI
parser error. Resolve the user install directory at install time and pass
--install-dir instead, which is semantically equivalent and avoids the conflict.
Uninstall is intentionally left unscoped so gem can find gems regardless of
where they were originally installed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* gem - add changelog fragment for #11873
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* gem - fix user_install handling for install and uninstall
Two issues found in CI:
1. `gem environment user_gemhome` is not supported on older RubyGems (e.g.
Ubuntu 20.04 ships 3.1.2). Simplify get_user_install_dir() to always parse
the full `gem environment` output for "USER INSTALLATION DIRECTORY", which
is stable across all supported versions.
2. On Fedora, `gem uninstall` without flags only searches the system gem path
(set by operating_system.rb), so it cannot find gems installed to the user
dir via --install-dir. Add user_install to the uninstall args_order so that
gem uninstall --user-install is passed when user_install=True. The OS
defaults conflict only applies to gem install, not gem uninstall.
The integration test is updated to be consistent: the user_install:false
install/remove block now also specifies user_install:false on removal.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* gem - use --install-dir for both install and uninstall of user gems
gem uninstall --user-install does not reliably find gems on Fedora/RHEL when
running as root, because those systems may disable user gem home for root and
Gem.user_dir may differ from the path resolved via 'gem environment'.
Use --install-dir <user_dir> for uninstall as well, since that is the exact
path used during install, making the operation consistent across platforms.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* gem - add override_platform_install_dir option and type hints
- add type hints to all functions
- fix misleading comment about --install-dir scoping for uninstall
- add override_platform_install_dir option (default=false) to opt in to
resolving and passing the user gem dir explicitly to both gem install
and gem uninstall, working around OS-injected platform defaults on
distributions such as Fedora
- reclassify changelog fragment as minor_changes (new parameter, not
backport-eligible)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(gem): add integration test for override_platform_install_dir
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(gem): skip default user_install test on RedHat family
OS-injected --install-dir on RHEL/Fedora makes the default user_install: true
case fail. The override_platform_install_dir block already covers the correct
path on those platforms.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>