diff --git a/changelogs/fragments/11442-gem-module-ruby-4.yml b/changelogs/fragments/11442-gem-module-ruby-4.yml new file mode 100644 index 0000000000..9314cb8acd --- /dev/null +++ b/changelogs/fragments/11442-gem-module-ruby-4.yml @@ -0,0 +1,2 @@ +bugfixes: + - "gem - add compatibility with Ruby 4 rubygems (https://github.com/ansible-collections/community.general/issues/11397, https://github.com/ansible-collections/community.general/pull/11442)." diff --git a/plugins/modules/gem.py b/plugins/modules/gem.py index de0984e3ea..afacb282bf 100644 --- a/plugins/modules/gem.py +++ b/plugins/modules/gem.py @@ -160,13 +160,12 @@ def get_rubygems_environ(module): def get_installed_versions(module, remote=False): cmd = get_rubygems_path(module) - cmd.append("query") + cmd.append("list") cmd.extend(common_opts(module)) if remote: cmd.append("--remote") if module.params["repository"]: cmd.extend(["--source", module.params["repository"]]) - cmd.append("-n") cmd.append(f"^{module.params['name']}$") environ = get_rubygems_environ(module)