diff --git a/src/Operations.jl b/src/Operations.jl index 013d163e58..007da6c98e 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -997,17 +997,15 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}) println(ctx.io, "No changes") return end - # only declare `compat` for direct dependencies + # only declare `compat` for remaining direct or `extra` dependencies # `julia` is always an implicit direct dependency filter!(ctx.env.project.compat) do (name, _) - name == "julia" || name in keys(ctx.env.project.deps) + name == "julia" || name in keys(ctx.env.project.deps) || name in keys(ctx.env.project.extras) end - deps_names = append!(collect(keys(ctx.env.project.deps)), - collect(keys(ctx.env.project.extras))) + deps_names = union(keys(ctx.env.project.deps), keys(ctx.env.project.extras)) filter!(ctx.env.project.targets) do (target, deps) !isempty(filter!(in(deps_names), deps)) end - # only keep reachable manifest entires prune_manifest(ctx.env) # update project & manifest diff --git a/test/new.jl b/test/new.jl index ae17526fed..1fafd6fca4 100644 --- a/test/new.jl +++ b/test/new.jl @@ -1722,6 +1722,16 @@ end @test !haskey(Pkg.Types.Context().env.project.compat, "Example") @test haskey(Pkg.Types.Context().env.project.compat, "julia") end end + # rm should not unnecessarily remove compat entries + isolate(loaded_depot=true) do; mktempdir() do tempdir + path = copy_test_package(tempdir, "CompatExtras") + Pkg.activate(path) + @test haskey(Pkg.Types.Context().env.project.compat, "Aqua") + @test haskey(Pkg.Types.Context().env.project.compat, "DataFrames") + Pkg.rm("DataFrames") + @test !haskey(Pkg.Types.Context().env.project.compat, "DataFrames") + @test haskey(Pkg.Types.Context().env.project.compat, "Aqua") + end end # rm removes unused recursive depdencies isolate(loaded_depot=true) do; mktempdir() do tempdir path = copy_test_package(tempdir, "SimplePackage") diff --git a/test/test_packages/CompatExtras/Project.toml b/test/test_packages/CompatExtras/Project.toml new file mode 100644 index 0000000000..fc36433e02 --- /dev/null +++ b/test/test_packages/CompatExtras/Project.toml @@ -0,0 +1,16 @@ +name = "CompatExtras" +uuid = "37f6bc05-9e90-43d5-90c6-4d69d7097606" +version = "0.1.0" + +[deps] +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + +[compat] +Aqua = "0.5" +DataFrames = "0.22" + +[extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" + +[targets] +test = ["Aqua"]