diff --git a/src/API.jl b/src/API.jl index 5cf4285130..867a1570f6 100644 --- a/src/API.jl +++ b/src/API.jl @@ -1149,12 +1149,15 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool # if the active environment is a package, add that ctx_env_pkg = ctx.env.pkg - if ctx_env_pkg !== nothing && isfile( joinpath( dirname(ctx.env.project_file), "src", "$(ctx_env_pkg.name).jl") ) - depsmap[Base.PkgId(ctx_env_pkg.uuid, ctx_env_pkg.name)] = [ + if ctx_env_pkg !== nothing && isfile(joinpath(dirname(ctx.env.project_file), "src", "$(ctx_env_pkg.name).jl")) + project_pkgid = Base.PkgId(ctx_env_pkg.uuid, ctx_env_pkg.name) + depsmap[project_pkgid] = [ Base.PkgId(last(x), first(x)) for x in ctx.env.project.deps if !Base.in_sysimage(Base.PkgId(last(x), first(x))) ] push!(direct_deps, Base.PkgId(ctx_env_pkg.uuid, ctx_env_pkg.name)) + else + project_pkgid = nothing end # return early if no deps @@ -1277,23 +1280,25 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool stderr_outputs = Dict{Base.PkgId,String}() taskwaiting = Set{Base.PkgId}() pkgspidlocked = Dict{Base.PkgId,String}() + pkg_liveprinted = nothing function monitor_stderr(pkg, iob; single_requested_pkg=false) try liveprinting = false while isopen(iob) - str = readline(iob) + str = readline(iob; keep=true) if single_requested_pkg && (liveprinting || !isempty(str)) lock(print_lock) do if !liveprinting - printpkgstyle(io, :Info, "Given `precompile $(pkg.name)` was explicitly requested, output will be shown live $ansi_cleartoendofline", + printpkgstyle(io, :Info, "Given $(pkg.name) was explicitly requested, output will be shown live $ansi_cleartoendofline", color = Base.info_color()) liveprinting = true + pkg_liveprinted = pkg end - println(io, str, ansi_cleartoendofline) + print(io, ansi_cleartoendofline, str) end end - stderr_outputs[pkg] = get(stderr_outputs, pkg, "") * str * "\n" + stderr_outputs[pkg] = string(get(stderr_outputs, pkg, ""), str) if !in(pkg, taskwaiting) && occursin("waiting for IO to finish", str) !fancyprint && lock(print_lock) do println(io, pkg.name, color_string(" Waiting for background task / IO / timer.", Base.warn_color())) @@ -1421,7 +1426,13 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool continue end - single_requested_pkg = length(pkgs) == 1 && only(pkgs).name == pkg.name + single_requested_pkg = if length(pkgs) == 1 + only(pkgs).name == pkg.name + elseif project_pkgid isa Base.PkgId + pkg == project_pkgid # if a package project is being precompiled, consider the package requested + else + false + end task = @async begin try @@ -1566,7 +1577,11 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool plural2 = length(stderr_outputs) == 1 ? "" : "s" print(iostr, "\n ", color_string("$(length(stderr_outputs))", Base.warn_color()), " dependenc$(plural1) had output during precompilation:") for (pkgid, err) in stderr_outputs - err = join(split(strip(err), "\n"), color_string("\n│ ", Base.warn_color())) + err = if pkgid == pkg_liveprinted + "Output shown above" + else + join(split(strip(err), "\n"), color_string("\n│ ", Base.warn_color())) + end print(iostr, color_string("\n┌ ", Base.warn_color()), pkgid, color_string("\n│ ", Base.warn_color()), err, color_string("\n└ ", Base.warn_color())) end end