Skip to content

Commit

Permalink
bundler: Pinning bundler version to the system one
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
a-ovchinnikov committed Oct 18, 2024
1 parent 3629152 commit dbdac14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cachi2/core/package_managers/bundler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/package_managers/bundler/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"""
)

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"
"""
)

Expand Down

0 comments on commit dbdac14

Please sign in to comment.