From 00060263a523344fed6b0e8f2a1227ae8c17a346 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Tue, 12 May 2026 21:00:45 +1200 Subject: [PATCH] bundler: replace deprecated CLI flags with `BUNDLE_*` env vars (#12024) * fix(bundler): replace deprecated CLI flags with BUNDLE_* env vars Bundler 2.1 deprecated --deployment, --without, --path, --clean, and --binstubs; Bundler 4 has removed --clean entirely. Pass these options as BUNDLE_* environment variables instead, which have been supported since Bundler 1.0.0 and are scoped to the process (no persistent .bundle/config written). Fixes #4583, fixes #11380 Co-Authored-By: Claude Sonnet 4.6 * fix(bundler): add changelog fragment for PR #12024 Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- .../fragments/12024-bundler-deprecated-flags.yml | 6 ++++++ plugins/modules/bundler.py | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/12024-bundler-deprecated-flags.yml diff --git a/changelogs/fragments/12024-bundler-deprecated-flags.yml b/changelogs/fragments/12024-bundler-deprecated-flags.yml new file mode 100644 index 0000000000..d2e2bca2af --- /dev/null +++ b/changelogs/fragments/12024-bundler-deprecated-flags.yml @@ -0,0 +1,6 @@ +bugfixes: + - "bundler - replace deprecated ``--deployment``, ``--without``, ``--path``, + ``--clean``, and ``--binstubs`` flags with ``BUNDLE_*`` environment variables, + fixing compatibility with Bundler 4 (https://github.com/ansible-collections/community.general/issues/4583, + https://github.com/ansible-collections/community.general/issues/11380, + https://github.com/ansible-collections/community.general/pull/12024)." diff --git a/plugins/modules/bundler.py b/plugins/modules/bundler.py index e0953d9c09..90fc750a23 100644 --- a/plugins/modules/bundler.py +++ b/plugins/modules/bundler.py @@ -165,24 +165,25 @@ def main(): module.exit_json(changed=rc != 0, state=state, stdout=out, stderr=err) + bundle_env = {} if state == "present": cmd.append("install") if exclude_groups: - cmd.extend(["--without", ":".join(exclude_groups)]) + bundle_env["BUNDLE_WITHOUT"] = ":".join(exclude_groups) if clean: - cmd.append("--clean") + bundle_env["BUNDLE_CLEAN"] = "true" if gemfile: cmd.extend(["--gemfile", gemfile]) if local: cmd.append("--local") if deployment_mode: - cmd.append("--deployment") + bundle_env["BUNDLE_DEPLOYMENT"] = "true" if not user_install: cmd.append("--system") if gem_path: - cmd.extend(["--path", gem_path]) + bundle_env["BUNDLE_PATH"] = gem_path if binstub_directory: - cmd.extend(["--binstubs", binstub_directory]) + bundle_env["BUNDLE_BIN"] = binstub_directory else: cmd.append("update") if local: @@ -191,7 +192,7 @@ def main(): if extra_args: cmd.extend(extra_args.split(" ")) - rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=True) + rc, out, err = module.run_command(cmd, cwd=chdir, check_rc=True, environ_update=bundle_env) module.exit_json(changed="Installing" in out, state=state, stdout=out, stderr=err)