From dbdac142f712df3249b1eccfaf7fc2a79af34cee Mon Sep 17 00:00:00 2001 From: Alexey Ovchinnikov Date: Fri, 18 Oct 2024 06:25:11 -0500 Subject: [PATCH] bundler: Pinning bundler version to the system one When there is a version mismatch between a lockfile and bundler used to build a package, bundler might try to install a version specified in the lockfile. This will result in a build failure in a hermetic environment. This change forces bundler to always use whichever version is present in the system by overriding BUNDLE_VERSION variable and setting it to 'system'. See https://bundler.io/v2.5/man/bundle-config.1.html#LIST-OF-AVAILABLE-KEYS for details. Signed-off-by: Alexey Ovchinnikov --- cachi2/core/package_managers/bundler/main.py | 1 + tests/unit/package_managers/bundler/test_main.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/cachi2/core/package_managers/bundler/main.py b/cachi2/core/package_managers/bundler/main.py index dce93f763..8ecea75e8 100644 --- a/cachi2/core/package_managers/bundler/main.py +++ b/cachi2/core/package_managers/bundler/main.py @@ -159,6 +159,7 @@ def _prepare_for_hermetic_build(source_dir: RootedPath, output_dir: RootedPath) BUNDLE_CACHE_PATH: "${output_dir}/deps/bundler" BUNDLE_DEPLOYMENT: "true" BUNDLE_NO_PRUNE: "true" + BUNDLE_VERSION: "system" """ ) if potential_bundle_config.is_file(): diff --git a/tests/unit/package_managers/bundler/test_main.py b/tests/unit/package_managers/bundler/test_main.py index 2fabe2283..1b2638bf5 100644 --- a/tests/unit/package_managers/bundler/test_main.py +++ b/tests/unit/package_managers/bundler/test_main.py @@ -127,6 +127,7 @@ def test__prepare_for_hermetic_build_injects_necessary_variable_into_empty_confi BUNDLE_CACHE_PATH: "${output_dir}/deps/bundler" BUNDLE_DEPLOYMENT: "true" BUNDLE_NO_PRUNE: "true" + BUNDLE_VERSION: "system" """ ) @@ -146,6 +147,7 @@ def test__prepare_for_hermetic_build_injects_necessary_variable_into_existing_co BUNDLE_CACHE_PATH: "${output_dir}/deps/bundler" BUNDLE_DEPLOYMENT: "true" BUNDLE_NO_PRUNE: "true" + BUNDLE_VERSION: "system" """ ) existing_preamble = dedent( @@ -175,6 +177,7 @@ def test__prepare_for_hermetic_build_injects_necessary_variable_into_existing_al BUNDLE_CACHE_PATH: "${output_dir}/deps/bundler" BUNDLE_DEPLOYMENT: "true" BUNDLE_NO_PRUNE: "true" + BUNDLE_VERSION: "system" """ ) existing_preamble = dedent( @@ -209,6 +212,7 @@ def test__prepare_for_hermetic_build_ignores_a_directory_in_place_of_config( BUNDLE_CACHE_PATH: "${output_dir}/deps/bundler" BUNDLE_DEPLOYMENT: "true" BUNDLE_NO_PRUNE: "true" + BUNDLE_VERSION: "system" """ )