1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-05-07 02:25:53 +00:00
community.general/plugins
Alexei Znamensky f5da5c9681
gem - fix --user-install conflict with OS-injected --install-dir (#11873)
* 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>
2026-05-04 07:28:56 +12:00
..
action Sort imports with ruff check --fix (#11400) 2026-01-09 07:40:58 +01:00
become pfexec become plugin: fix broken defaults for illumos/SmartOS (#11623) 2026-04-25 21:12:36 +02:00
cache Sort imports with ruff check --fix (#11400) 2026-01-09 07:40:58 +01:00
callback selective callback plugin: route output through display to honour ANSIBLE_LOG_PATH (#11927) 2026-04-29 21:25:43 +02:00
connection Make all doc fragments, module utils, and plugin utils private (#11896) 2026-04-20 20:16:26 +02:00
doc_fragments Make all doc fragments, module utils, and plugin utils private (#11896) 2026-04-20 20:16:26 +02:00
filter Replace % string formatting with f-strings across multiple plugins (#11908) 2026-04-22 07:06:27 +12:00
inventory Fix nmap inventory plugin: skip setting reserved 'name' variable (#11893) 2026-04-25 21:07:19 +02:00
lookup lmdb_kv lookup, guide_alicloud: fix deprecated list-format vars: in examples and docs (#11942) 2026-04-30 12:36:13 +12:00
module_utils snap: add revision parameter (#11984) 2026-05-04 07:28:06 +12:00
modules gem - fix --user-install conflict with OS-injected --install-dir (#11873) 2026-05-04 07:28:56 +12:00
plugin_utils Replace % string formatting with f-strings across multiple plugins (#11908) 2026-04-22 07:06:27 +12:00
test Make all doc fragments, module utils, and plugin utils private (#11896) 2026-04-20 20:16:26 +02:00