Skip to content

Commit 5b100cc

Browse files
authored
Handle multiple versions of the same app during releases (#9102)
1 parent 4428e56 commit 5b100cc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/mix/lib/mix/release.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ defmodule Mix.Release do
246246
path -> do_load_app(app, path, seen, otp_root, false)
247247
end
248248

249-
[path] ->
249+
paths ->
250+
path = paths |> Enum.sort() |> List.last()
250251
do_load_app(app, to_charlist(path), seen, otp_root, true)
251252
end
252253
end

lib/mix/test/mix/release_test.exs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ defmodule Mix.ReleaseTest do
110110
end
111111
end
112112

113+
test "uses the latest version of an app if there are multiple versions", context do
114+
in_tmp(context.test, fn ->
115+
File.cp_r!(:code.root_dir(), ".", fn _, _ -> false end)
116+
File.mkdir_p!("lib/compiler-1.0")
117+
erts_source = Path.join(File.cwd!(), "erts-#{@erts_version}")
118+
119+
release = from_config!(nil, config(releases: [demo: [include_erts: erts_source]]), [])
120+
121+
assert release.applications.compiler[:vsn] != "1.0"
122+
end)
123+
end
124+
113125
test "raises on unknown app" do
114126
assert_raise Mix.Error, "Could not find application :unknown", fn ->
115127
from_config!(nil, config(releases: [demo: [applications: [unknown: :none]]]), [])
@@ -537,7 +549,7 @@ defmodule Mix.ReleaseTest do
537549
assert File.exists?(Path.join(@release_lib, "runtime_tools-#{@runtime_tools_version}/priv"))
538550
end
539551

540-
test "does not copy OTP app if include_erts is false" do
552+
test "does not copy OTP app if include_erts is false" do
541553
release = release(include_erts: false, applications: [runtime_tools: :permanent])
542554
refute copy_app(release, :runtime_tools)
543555
refute File.exists?(Path.join(@release_lib, "runtime_tools-#{@runtime_tools_version}/ebin"))

0 commit comments

Comments
 (0)