Skip to content

Commit d3c34f6

Browse files
fix
1 parent dfd2675 commit d3c34f6

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

src/coveralls_functions.jl

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,18 @@ function install_local_homebrew(local_homebrew_dir, local_brew_path)
208208

209209
# Post-install setup with better error handling
210210
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-
220211
# Create cache and temp directories
221-
mkpath(homebrew_env["HOMEBREW_CACHE"])
222-
mkpath(homebrew_env["HOMEBREW_TEMP"])
223-
224-
withenv(homebrew_env) do
212+
cache_dir = joinpath(local_homebrew_dir, "cache")
213+
temp_dir = joinpath(local_homebrew_dir, "temp")
214+
mkpath(cache_dir)
215+
mkpath(temp_dir)
216+
217+
withenv("HOMEBREW_NO_AUTO_UPDATE" => "1",
218+
"HOMEBREW_NO_INSTALL_CLEANUP" => "1",
219+
"HOMEBREW_NO_ANALYTICS" => "1",
220+
"HOMEBREW_CACHE" => cache_dir,
221+
"HOMEBREW_TEMP" => temp_dir,
222+
"TMPDIR" => temp_dir) do
225223
run(`$local_brew_path update --force --quiet`)
226224
end
227225
catch e
@@ -240,37 +238,43 @@ function install_coveralls_with_homebrew(brew_cmd, reporter_info, coveralls_path
240238
homebrew_type = use_local_homebrew ? "local Homebrew" : "system Homebrew"
241239
@info "Installing Coveralls reporter via $homebrew_type..."
242240

243-
# Set up environment for local Homebrew
244-
homebrew_env = copy(ENV)
245-
if use_local_homebrew
241+
# Set up environment variables for local Homebrew
242+
local_env_vars = if use_local_homebrew
246243
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-
244+
cache_dir = joinpath(local_homebrew_dir, "cache")
245+
temp_dir = joinpath(local_homebrew_dir, "temp")
246+
258247
# Ensure directories exist
259-
mkpath(homebrew_env["HOMEBREW_CACHE"])
260-
mkpath(homebrew_env["HOMEBREW_TEMP"])
248+
mkpath(cache_dir)
249+
mkpath(temp_dir)
261250

262251
# Set additional permissions to handle CI environments
263252
try
264-
chmod(homebrew_env["HOMEBREW_CACHE"], 0o755)
265-
chmod(homebrew_env["HOMEBREW_TEMP"], 0o755)
253+
chmod(cache_dir, 0o755)
254+
chmod(temp_dir, 0o755)
266255
catch e
267256
@debug "Could not set directory permissions: $e"
268257
end
258+
259+
[
260+
"HOMEBREW_NO_AUTO_UPDATE" => "1",
261+
"HOMEBREW_NO_INSTALL_CLEANUP" => "1",
262+
"HOMEBREW_NO_ANALYTICS" => "1",
263+
"HOMEBREW_CACHE" => cache_dir,
264+
"HOMEBREW_TEMP" => temp_dir,
265+
"TMPDIR" => temp_dir,
266+
"HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK" => "1",
267+
"HOMEBREW_FORCE_BREWED_CURL" => "1",
268+
"HOMEBREW_NO_ENV_HINTS" => "1",
269+
"HOMEBREW_QUIET" => "1"
270+
]
271+
else
272+
[]
269273
end
270274

271275
# Add tap (ignore failures)
272276
try
273-
withenv(homebrew_env) do
277+
withenv(local_env_vars...) do
274278
run(`$brew_cmd tap $(reporter_info.tap)`)
275279
end
276280
catch e
@@ -280,7 +284,7 @@ function install_coveralls_with_homebrew(brew_cmd, reporter_info, coveralls_path
280284
# Install coveralls
281285
install_cmd = force ? "reinstall" : "install"
282286
try
283-
withenv(homebrew_env) do
287+
withenv(local_env_vars...) do
284288
# For local Homebrew, try to install with more permissive settings
285289
if use_local_homebrew
286290
run(`$brew_cmd $install_cmd $(reporter_info.package) --force-bottle`)

0 commit comments

Comments
 (0)