@@ -128,7 +128,7 @@ Returns (brew_cmd, use_local, local_homebrew_dir, local_brew_path).
128
128
function detect_homebrew_status ()
129
129
local_homebrew_dir = @get_scratch! (" local_homebrew" )
130
130
local_brew_path = joinpath (local_homebrew_dir, " bin" , " brew" )
131
-
131
+
132
132
# Try system Homebrew first
133
133
system_brew_cmd = Sys. which (" brew" )
134
134
if system_brew_cmd != = nothing
@@ -143,7 +143,7 @@ function detect_homebrew_status()
143
143
@debug " System Homebrew check failed: $e "
144
144
end
145
145
end
146
-
146
+
147
147
@info " Using local Homebrew installation"
148
148
return (local_brew_path, true , local_homebrew_dir, local_brew_path)
149
149
end
@@ -187,27 +187,47 @@ Install a local Homebrew instance.
187
187
"""
188
188
function install_local_homebrew (local_homebrew_dir, local_brew_path)
189
189
@info " Installing local Homebrew to: $local_homebrew_dir "
190
-
190
+
191
191
mkpath (local_homebrew_dir)
192
192
193
193
# Download and extract Homebrew
194
194
latest_release_url = " https://api.github.com/repos/Homebrew/brew/releases/latest"
195
195
response = HTTP. get (latest_release_url)
196
196
release_data = JSON. parse (String (response. body))
197
197
tarball_url = release_data[" tarball_url" ]
198
-
198
+
199
199
tarball_path = joinpath (local_homebrew_dir, " homebrew-latest.tar.gz" )
200
200
Downloads. download (tarball_url, tarball_path)
201
-
201
+
202
202
run (` tar -xzf $tarball_path -C $local_homebrew_dir --strip-components=1` )
203
203
rm (tarball_path)
204
-
204
+
205
205
if ! isfile (local_brew_path)
206
206
error (" Homebrew extraction failed - brew executable not found" )
207
207
end
208
208
209
- # Post-install setup
210
- run (` $local_brew_path update --force --quiet` )
209
+ # Post-install setup with better error handling
210
+ try
211
+ # Set environment variables for local Homebrew
212
+ homebrew_env = copy (ENV )
213
+ homebrew_env[" HOMEBREW_NO_AUTO_UPDATE" ] = " 1"
214
+ homebrew_env[" HOMEBREW_NO_INSTALL_CLEANUP" ] = " 1"
215
+ homebrew_env[" HOMEBREW_NO_ANALYTICS" ] = " 1"
216
+ homebrew_env[" HOMEBREW_CACHE" ] = joinpath (local_homebrew_dir, " cache" )
217
+ homebrew_env[" HOMEBREW_TEMP" ] = joinpath (local_homebrew_dir, " temp" )
218
+ homebrew_env[" TMPDIR" ] = joinpath (local_homebrew_dir, " temp" )
219
+
220
+ # Create cache and temp directories
221
+ mkpath (homebrew_env[" HOMEBREW_CACHE" ])
222
+ mkpath (homebrew_env[" HOMEBREW_TEMP" ])
223
+
224
+ withenv (homebrew_env) do
225
+ run (` $local_brew_path update --force --quiet` )
226
+ end
227
+ catch e
228
+ @warn " Homebrew post-install setup failed, but continuing: $e "
229
+ end
230
+
211
231
@info " Local Homebrew installed successfully"
212
232
end
213
233
@@ -220,26 +240,65 @@ function install_coveralls_with_homebrew(brew_cmd, reporter_info, coveralls_path
220
240
homebrew_type = use_local_homebrew ? " local Homebrew" : " system Homebrew"
221
241
@info " Installing Coveralls reporter via $homebrew_type ..."
222
242
243
+ # Set up environment for local Homebrew
244
+ homebrew_env = copy (ENV )
245
+ if use_local_homebrew
246
+ local_homebrew_dir = dirname (dirname (brew_cmd)) # Get parent of bin directory
247
+ homebrew_env[" HOMEBREW_NO_AUTO_UPDATE" ] = " 1"
248
+ homebrew_env[" HOMEBREW_NO_INSTALL_CLEANUP" ] = " 1"
249
+ homebrew_env[" HOMEBREW_NO_ANALYTICS" ] = " 1"
250
+ homebrew_env[" HOMEBREW_CACHE" ] = joinpath (local_homebrew_dir, " cache" )
251
+ homebrew_env[" HOMEBREW_TEMP" ] = joinpath (local_homebrew_dir, " temp" )
252
+ homebrew_env[" TMPDIR" ] = joinpath (local_homebrew_dir, " temp" )
253
+ homebrew_env[" HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK" ] = " 1"
254
+ homebrew_env[" HOMEBREW_FORCE_BREWED_CURL" ] = " 1"
255
+ homebrew_env[" HOMEBREW_NO_ENV_HINTS" ] = " 1"
256
+ homebrew_env[" HOMEBREW_QUIET" ] = " 1"
257
+
258
+ # Ensure directories exist
259
+ mkpath (homebrew_env[" HOMEBREW_CACHE" ])
260
+ mkpath (homebrew_env[" HOMEBREW_TEMP" ])
261
+
262
+ # Set additional permissions to handle CI environments
263
+ try
264
+ chmod (homebrew_env[" HOMEBREW_CACHE" ], 0o755 )
265
+ chmod (homebrew_env[" HOMEBREW_TEMP" ], 0o755 )
266
+ catch e
267
+ @debug " Could not set directory permissions: $e "
268
+ end
269
+ end
270
+
223
271
# Add tap (ignore failures)
224
272
try
225
- run (` $brew_cmd tap $(reporter_info. tap) ` )
273
+ withenv (homebrew_env) do
274
+ run (` $brew_cmd tap $(reporter_info. tap) ` )
275
+ end
226
276
catch e
227
277
@debug " Tap command failed (possibly already exists): $e "
228
278
end
229
279
230
280
# Install coveralls
231
281
install_cmd = force ? " reinstall" : " install"
232
282
try
233
- run (` $brew_cmd $install_cmd $(reporter_info. package) ` )
283
+ withenv (homebrew_env) do
284
+ # For local Homebrew, try to install with more permissive settings
285
+ if use_local_homebrew
286
+ run (` $brew_cmd $install_cmd $(reporter_info. package) --force-bottle` )
287
+ else
288
+ run (` $brew_cmd $install_cmd $(reporter_info. package) ` )
289
+ end
290
+ end
234
291
catch e
235
- @debug " Install command failed (possibly already installed): $e "
292
+ @error " Install command failed: $e "
293
+ # Re-throw to let caller handle the error
294
+ rethrow (e)
236
295
end
237
296
238
297
# Verify installation
239
298
if ! isfile (coveralls_path)
240
299
error (" Coveralls installation failed - not found at: $coveralls_path " )
241
300
end
242
-
301
+
243
302
@info " Coveralls reporter installed at: $coveralls_path "
244
303
return coveralls_path
245
304
end
@@ -297,7 +356,7 @@ function get_coveralls_executable(; auto_download=true, install_dir=nothing)
297
356
# For macOS, check Homebrew installations
298
357
if platform == :macos
299
358
_, use_local_homebrew, local_homebrew_dir, _ = detect_homebrew_status ()
300
-
359
+
301
360
# Check system Homebrew if available
302
361
if ! use_local_homebrew
303
362
system_brew_cmd = Sys. which (" brew" )
@@ -314,7 +373,7 @@ function get_coveralls_executable(; auto_download=true, install_dir=nothing)
314
373
end
315
374
end
316
375
end
317
-
376
+
318
377
# Check local Homebrew installation
319
378
local_coveralls_path = joinpath (local_homebrew_dir, " bin" , " coveralls" )
320
379
if isfile (local_coveralls_path)
0 commit comments