diff --git a/lib/mix/lib/mix/dep/lock.ex b/lib/mix/lib/mix/dep/lock.ex index a8ec7192f56..74e7eb7bef9 100644 --- a/lib/mix/lib/mix/dep/lock.ex +++ b/lib/mix/lib/mix/dep/lock.ex @@ -42,7 +42,7 @@ defmodule Mix.Dep.Lock do def write(map, opts \\ []) do lockfile = opts[:file] || lockfile() - if map != read() do + if map != read(lockfile) do if Keyword.get(opts, :check_locked, false) do Mix.raise( "Your #{lockfile} is out of date and must be updated without the --check-locked flag" diff --git a/lib/mix/test/mix/dep/lock_test.exs b/lib/mix/test/mix/dep/lock_test.exs index 010efc15622..2800a9d0c22 100644 --- a/lib/mix/test/mix/dep/lock_test.exs +++ b/lib/mix/test/mix/dep/lock_test.exs @@ -46,6 +46,17 @@ defmodule Mix.Dep.LockTest do end) end + test "does not raise with check_locked when custom lockfile is unchanged", context do + in_tmp(context.test, fn -> + custom_lockfile = Path.expand("custom.lock") + + Mix.Dep.Lock.write(%{foo: :bar}) + Mix.Dep.Lock.write(%{bar: :baz}, file: custom_lockfile) + + Mix.Dep.Lock.write(%{bar: :baz}, file: custom_lockfile, check_locked: true) + end) + end + test "raises a proper error if check_locked opt is true and there are changes", context do in_tmp(context.test, fn -> Mix.Dep.Lock.write(%{foo: :bar})