File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ namespace :bundler do
4+ desc "Clear a corrupted shared bundle when bundle check reports broken native extensions"
5+ task :recover_shared_bundle do
6+ on fetch ( :bundle_servers ) do
7+ within release_path do
8+ with fetch ( :bundle_env_variables ) do
9+ invoke "bundler:config"
10+
11+ check_output = capture (
12+ :bash ,
13+ "-lc" ,
14+ <<~BASH
15+ set +e
16+ output="$(bundle check 2>&1)"
17+ status=$?
18+ printf '%s\n __BUNDLE_CHECK_STATUS__=%s\n ' "$output" "$status"
19+ BASH
20+ )
21+
22+ broken_extensions = check_output . include? ( "because its extensions are not built" )
23+ missing_gems = check_output . include? ( "Bundler::GemNotFound" )
24+
25+ next unless broken_extensions || missing_gems
26+
27+ warn "Bundler reported a corrupted shared bundle. Removing #{ fetch ( :bundle_path ) } before reinstalling gems."
28+ execute :rm , "-rf" , fetch ( :bundle_path )
29+ end
30+ end
31+ end
32+ end
33+ end
34+
35+ before "bundler:install" , "bundler:recover_shared_bundle"
You can’t perform that action at this time.
0 commit comments