* 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>
* Add Fedora 41, Alpine 3.21, RHEL 9.5, FreeBSD 14.2 to CI for devel.
* Add some ignores that are likely needed.
* Try to fix/ignore various errors.
* Fix redis setup on Fedora 41.
* Undo disable yum_versionlock since it's already globally disabled.
* gem_module: Add bindir option
This option allows to specify directory to install executables, e.g.
`/home/user/bin` or `/home/user/.local/bin`. This comes especially handy
when used with user_install option as the default path of executables is
not in PATH.
* Update changelogs/fragments/gem_module_add_bindir_option.yml
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
* gem_module: Integration tests for bindir option
* gem_module: Update Integration tests for bindir option
* gem_module: Update Integration tests for bindir option
Make sure gist is not installed system-wide prior the tests
* Revert "gem_module: Update Integration tests for bindir option"
This reverts commit 04eec6db27.
* Do not check "install_gem_result is changed" for ansible develop on openSUSE
* Revert "Do not check "install_gem_result is changed" for ansible develop on openSUSE"
This reverts commit 48ecb27889.
* gem_module: Use --norc to avoid surprises
Run install and uninstall actions with `--norc`. This way ansible has
more control over the way gems are installed.
* Revert "gem_module: Use --norc to avoid surprises"
This reverts commit 66f40bcfe6.
* gem_module: bindir - Ignore openSUSE Leap
* Update plugins/modules/packaging/language/gem.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* gem_module: Use --norc to avoid surprises
Run install and uninstall actions with `--norc` when supported (rubygems >= 2.5.2).
This way ansible has more control over the way gems are installed.
* Try distutils.version instead of packaging
* ver is an list, not string
* ver is not list either but tuple
* Update changelogs/fragments/gem_module_add_bindir_option.yml
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
* ver can be None (when can this happen?)
* gem: Add norc option
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/packaging/language/gem.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Use tuples to compare versions
* Apply suggestions from code review
Co-authored-by: Amin Vakil <info@aminvakil.com>
* Update plugins/modules/packaging/language/gem.py
Co-authored-by: Amin Vakil <info@aminvakil.com>
* lost norc option check is back
* Move handling norc option to separate function
* cosmetic
* fix for the previos commit
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Cache result of get_rubygems_version
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Amin Vakil <info@aminvakil.com>