Skip to content

Commit 88b512e

Browse files
Precompile: add strict kwarg to control whether indirect deps throw (#2362)
* add fail_indirect_deps kwarg * update pkgerror to reflect fail_indirect_deps * change kwarg to throw_indirect_deps * fix spacing * better docstring wording * switch to `strict` (cherry picked from commit 8fbdbd9)
1 parent c6f495c commit 88b512e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/API.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ function make_pkgspec(man, uuid)
910910
end
911911

912912
precompile(; kwargs...) = precompile(Context(); kwargs...)
913-
function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
913+
function precompile(ctx::Context; internal_call::Bool=false, strict::Bool=false, kwargs...)
914914
Context!(ctx; kwargs...)
915915
instantiate(ctx; allow_autoprecomp=false, kwargs...)
916916
time_start = time_ns()
@@ -1144,7 +1144,7 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
11441144
end
11451145
catch err
11461146
if err isa ErrorException
1147-
failed_deps[pkg] = is_direct_dep ? String(take!(iob)) : ""
1147+
failed_deps[pkg] = (strict || is_direct_dep) ? String(take!(iob)) : ""
11481148
!fancyprint && lock(print_lock) do
11491149
println(io, string(color_string("", Base.error_color()), name))
11501150
end
@@ -1213,15 +1213,16 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
12131213
err_str = ""
12141214
n_direct_errs = 0
12151215
for (dep, err) in failed_deps
1216-
if dep in direct_deps
1216+
if strict || (dep in direct_deps)
12171217
err_str *= "\n" * "$dep" * "\n\n" * err * (n_direct_errs > 0 ? "\n" : "")
12181218
n_direct_errs += 1
12191219
end
12201220
end
12211221
if err_str != ""
12221222
println(io, "")
12231223
plural = n_direct_errs == 1 ? "y" : "ies"
1224-
pkgerror("The following $( n_direct_errs) direct dependenc$(plural) failed to precompile:\n$(err_str[1:end-1])")
1224+
direct = strict ? "" : "direct "
1225+
pkgerror("The following $n_direct_errs $(direct)dependenc$(plural) failed to precompile:\n$(err_str[1:end-1])")
12251226
end
12261227
end
12271228
end

src/Pkg.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ See also [`PackageSpec`](@ref).
127127
const add = API.add
128128

129129
"""
130-
Pkg.precompile()
130+
Pkg.precompile(; strict::Bool=false)
131131
132132
Precompile all the dependencies of the project in parallel.
133133
!!! note
134134
Errors will only throw when precompiling the top-level dependencies, given that
135135
not all manifest dependencies may be loaded by the top-level dependencies on the given system.
136+
This can be overridden to make errors in all dependencies throw by setting the kwarg `strict` to `true`
136137
137138
!!! note
138139
This method is called automatically after any Pkg action that changes the manifest.

0 commit comments

Comments
 (0)