Skip to content

Commit

Permalink
Fix Pkg.build when run on a non-installed package (#16584)
Browse files Browse the repository at this point in the history
* Fix Pkg.build when run on a non-installed package

* Avoid SIGTERM when PkgError occurs with Pkg.build
  • Loading branch information
omus authored and tkelman committed May 27, 2016
1 parent 8584040 commit 58d45ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ end
function build!(pkgs::Vector, buildstream::IO, seen::Set)
for pkg in pkgs
pkg == "julia" && continue
pkg in seen && continue
build!(Read.requires_list(pkg),buildstream,push!(seen,pkg))
pkg in seen ? continue : push!(seen,pkg)
Read.isinstalled(pkg) || throw(PkgError("$pkg is not an installed package"))
build!(Read.requires_list(pkg),buildstream,seen)
path = abspath(pkg,"deps","build.jl")
isfile(path) || continue
println(buildstream, path) # send to build process for evalfile
Expand Down Expand Up @@ -582,8 +582,8 @@ function build!(pkgs::Vector, errs::Dict, seen::Set=Set())
end
end
catch err
kill(pobj)
close(io)
isa(err, PkgError) ? wait(pobj) : kill(pobj)
rethrow(err)
finally
isfile(errfile) && Base.rm(errfile)
Expand Down
9 changes: 9 additions & 0 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,13 @@ temp_pkg_dir() do
@test contains(msg, "Pkg.build(\"BuildFail\")")
@test contains(msg, "Throw build error")
end

# issue #15948
let package = "Example"
Pkg.rm(package) # Remove package if installed
@test Pkg.installed(package) == nothing # Registered with METADATA but not installed
msg = readstring(ignorestatus(`$(Base.julia_cmd()) -f -e "redirect_stderr(STDOUT); Pkg.build(\"$package\")"`))
@test contains(msg, "$package is not an installed package")
@test !contains(msg, "signal (15)")
end
end

0 comments on commit 58d45ea

Please sign in to comment.