@@ -484,8 +484,8 @@ def install
484
484
if pour_bottle?
485
485
begin
486
486
pour
487
+ # Catch any other types of exceptions as they leave us with nothing installed.
487
488
rescue Exception # rubocop:disable Lint/RescueException
488
- # any exceptions must leave us with nothing installed
489
489
ignore_interrupts do
490
490
begin
491
491
FileUtils . rm_r ( formula . prefix ) if formula . prefix . directory?
@@ -825,6 +825,7 @@ def install_dependency(dep, inherited_options)
825
825
oh1 "Installing #{ formula . full_name } dependency: #{ Formatter . identifier ( dep . name ) } "
826
826
fi . install
827
827
fi . finish
828
+ # Handle all possible exceptions installing deps.
828
829
rescue Exception => e # rubocop:disable Lint/RescueException
829
830
ignore_interrupts do
830
831
tmp_keg . rename ( installed_keg . to_path ) if tmp_keg && !installed_keg . directory?
@@ -1022,6 +1023,7 @@ def build
1022
1023
formula . update_head_version
1023
1024
1024
1025
raise "Empty installation" if !formula . prefix . directory? || Keg . new ( formula . prefix ) . empty_installation?
1026
+ # Handle all possible exceptions when building.
1025
1027
rescue Exception => e # rubocop:disable Lint/RescueException
1026
1028
if e . is_a? BuildError
1027
1029
e . formula = formula
@@ -1099,6 +1101,7 @@ def link(keg)
1099
1101
puts "You can try again using:"
1100
1102
puts " brew link #{ formula . name } "
1101
1103
@show_summary_heading = true
1104
+ # Handle all other possible exceptions when linking.
1102
1105
rescue Exception => e # rubocop:disable Lint/RescueException
1103
1106
ofail "An unexpected error occurred during the `brew link` step"
1104
1107
puts "The formula built, but is not symlinked into #{ HOMEBREW_PREFIX } "
@@ -1151,6 +1154,7 @@ def install_service
1151
1154
launchd_service_path . chmod 0644
1152
1155
log = formula . var /"log"
1153
1156
log . mkpath if service . include? log . to_s
1157
+ # Handle all possible exceptions when installing service files.
1154
1158
rescue Exception => e # rubocop:disable Lint/RescueException
1155
1159
puts e
1156
1160
ofail "Failed to install service files"
@@ -1162,6 +1166,7 @@ def install_service
1162
1166
sig { params ( keg : Keg ) . void }
1163
1167
def fix_dynamic_linkage ( keg )
1164
1168
keg . fix_dynamic_linkage
1169
+ # Rescue all possible exceptions when fixing linkage.
1165
1170
rescue Exception => e # rubocop:disable Lint/RescueException
1166
1171
ofail "Failed to fix install linkage"
1167
1172
puts "The formula built, but you may encounter issues using it or linking other"
@@ -1177,6 +1182,7 @@ def fix_dynamic_linkage(keg)
1177
1182
def clean
1178
1183
ohai "Cleaning" if verbose?
1179
1184
Cleaner . new ( formula ) . clean
1185
+ # Handle all possible exceptions when cleaning does not complete.
1180
1186
rescue Exception => e # rubocop:disable Lint/RescueException
1181
1187
opoo "The cleaning step did not complete successfully"
1182
1188
puts "Still, the installation was successful, so we will link it into your prefix."
@@ -1249,6 +1255,7 @@ def post_install
1249
1255
exec ( *args )
1250
1256
end
1251
1257
end
1258
+ # Handle all possible exceptions when postinstall does not complete.
1252
1259
rescue Exception => e # rubocop:disable Lint/RescueException
1253
1260
opoo "The post-install step did not complete successfully"
1254
1261
puts "You can try again using:"
0 commit comments