Skip to content

Commit 7580c4f

Browse files
IanButterworthKristofferC
authored andcommitted
precompilepkgs: fix error path & adjust messaging (#53772)
Fixes issues with the handling of errored dependencies (cherry picked from commit a9611ce)
1 parent c2fd281 commit 7580c4f

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

base/precompilation.jl

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,10 @@ function precompilepkgs(pkgs::Vector{String}=String[];
463463
was_recompiled = Dict{PkgConfig,Bool}()
464464
for config in configs
465465
for pkgid in keys(depsmap)
466-
dep_config = (pkgid, config)
467-
started[dep_config] = false
468-
was_processed[dep_config] = Base.Event()
469-
was_recompiled[dep_config] = false
466+
pkg_config = (pkgid, config)
467+
started[pkg_config] = false
468+
was_processed[pkg_config] = Base.Event()
469+
was_recompiled[pkg_config] = false
470470
end
471471
end
472472
@debug "precompile: signalling initialized"
@@ -501,9 +501,9 @@ function precompilepkgs(pkgs::Vector{String}=String[];
501501
for pkg in keys(depsmap)
502502
if scan_pkg!(pkg, depsmap)
503503
push!(circular_deps, pkg)
504-
for dep_config in keys(was_processed)
504+
for pkg_config in keys(was_processed)
505505
# notify all to allow skipping
506-
dep_config[1] == pkg && notify(was_processed[dep_config])
506+
pkg_config[1] == pkg && notify(was_processed[pkg_config])
507507
end
508508
end
509509
end
@@ -552,8 +552,8 @@ function precompilepkgs(pkgs::Vector{String}=String[];
552552
target = "project"
553553
end
554554
nconfig = length(configs)
555-
if nconfig > 1 || !isempty(only(configs)[1]) # if multiple configs or only one is not default
556-
target *= " for $nconfig compilation configuration$(nconfig > 1 ? "s" : "")..."
555+
if nconfig > 1
556+
target *= " for $nconfig compilation configurations..."
557557
else
558558
target *= "..."
559559
end
@@ -672,35 +672,35 @@ function precompilepkgs(pkgs::Vector{String}=String[];
672672
str = sprint(io -> show_progress(io, bar; termwidth, carriagereturn=false); context=io)
673673
print(iostr, Base._truncate_at_width_or_chars(true, str, termwidth), "\n")
674674
end
675-
for dep_config in pkg_queue_show
676-
dep, config = dep_config
675+
for pkg_config in pkg_queue_show
676+
dep, config = pkg_config
677677
loaded = warn_loaded && haskey(Base.loaded_modules, dep)
678678
_name = haskey(exts, dep) ? string(exts[dep], "", dep.name) : dep.name
679679
name = dep in direct_deps ? _name : string(color_string(_name, :light_black))
680-
if length(configs) > 1
681-
config_str = isempty(config[1]) ? "" : "$(join(config[1], " "))"
680+
if !isempty(config[1])
681+
config_str = "$(join(config[1], " "))"
682682
name *= color_string(" $(config_str)", :light_black)
683683
end
684-
line = if dep_config in precomperr_deps
684+
line = if pkg_config in precomperr_deps
685685
string(color_string(" ? ", Base.warn_color()), name)
686-
elseif haskey(failed_deps, dep_config)
686+
elseif haskey(failed_deps, pkg_config)
687687
string(color_string("", Base.error_color()), name)
688-
elseif was_recompiled[dep_config]
688+
elseif was_recompiled[pkg_config]
689689
!loaded && interrupted_or_done.set && continue
690690
loaded || @async begin # keep successful deps visible for short period
691691
sleep(1);
692-
filter!(!isequal(dep_config), pkg_queue)
692+
filter!(!isequal(pkg_config), pkg_queue)
693693
end
694694
string(color_string("", loaded ? Base.warn_color() : :green), name)
695-
elseif started[dep_config]
695+
elseif started[pkg_config]
696696
# Offset each spinner animation using the first character in the package name as the seed.
697697
# If not offset, on larger terminal fonts it looks odd that they all sync-up
698698
anim_char = anim_chars[(i + Int(dep.name[1])) % length(anim_chars) + 1]
699699
anim_char_colored = dep in direct_deps ? anim_char : color_string(anim_char, :light_black)
700-
waiting = if haskey(pkgspidlocked, dep_config)
701-
who_has_lock = pkgspidlocked[dep_config]
700+
waiting = if haskey(pkgspidlocked, pkg_config)
701+
who_has_lock = pkgspidlocked[pkg_config]
702702
color_string(" Being precompiled by $(who_has_lock)", Base.info_color())
703-
elseif dep_config in taskwaiting
703+
elseif pkg_config in taskwaiting
704704
color_string(" Waiting for background task / IO / timer. Interrupt to inspect", Base.warn_color())
705705
else
706706
""
@@ -769,8 +769,8 @@ function precompilepkgs(pkgs::Vector{String}=String[];
769769

770770
_name = haskey(exts, pkg) ? string(exts[pkg], "", pkg.name) : pkg.name
771771
name = is_direct_dep ? _name : string(color_string(_name, :light_black))
772-
if length(configs) > 1
773-
config_str = isempty(config[1]) ? "" : "$(join(config[1], " "))"
772+
if !isempty(flags)
773+
config_str = "$(join(flags, " "))"
774774
name *= color_string(" $(config_str)", :light_black)
775775
end
776776
!fancyprint && lock(print_lock) do
@@ -809,7 +809,7 @@ function precompilepkgs(pkgs::Vector{String}=String[];
809809
close(std_pipe.in) # close pipe to end the std output monitor
810810
wait(t_monitor)
811811
if err isa ErrorException || (err isa ArgumentError && startswith(err.msg, "Invalid header in cache file"))
812-
failed_deps[dep_config] = (strict || is_direct_dep) ? string(sprint(showerror, err), "\n", strip(get(std_outputs, pkg, ""))) : ""
812+
failed_deps[pkg_config] = (strict || is_direct_dep) ? string(sprint(showerror, err), "\n", strip(get(std_outputs, pkg, ""))) : ""
813813
delete!(std_outputs, pkg_config) # so it's not shown as warnings, given error report
814814
!fancyprint && lock(print_lock) do
815815
println(io, " "^9, color_string("", Base.error_color()), name)
@@ -907,9 +907,11 @@ function precompilepkgs(pkgs::Vector{String}=String[];
907907
quick_exit && return
908908
err_str = ""
909909
n_direct_errs = 0
910-
for (dep, err) in failed_deps
910+
for (pkg_config, err) in failed_deps
911+
dep, config = pkg_config
911912
if strict || (dep in direct_deps)
912-
err_str = string(err_str, "\n$dep\n\n$err", (n_direct_errs > 0 ? "\n" : ""))
913+
config_str = isempty(config[1]) ? "" : "$(join(config[1], " ")) "
914+
err_str = string(err_str, "\n$(dep.name) $config_str\n\n$err", (n_direct_errs > 0 ? "\n" : ""))
913915
n_direct_errs += 1
914916
end
915917
end

0 commit comments

Comments
 (0)