From a7565573630abf68b76b29b2e220ba8414ae54ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Sun, 30 Oct 2022 15:17:57 +0100 Subject: [PATCH] lock => the lock in solver failure messages --- lib/hex/solver.ex | 10 +++++++--- lib/hex/solver/assignment.ex | 2 +- lib/hex/solver/constraint.ex | 2 +- lib/hex/solver/constraints/empty.ex | 2 +- lib/hex/solver/constraints/impl.ex | 2 +- lib/hex/solver/constraints/range.ex | 2 +- lib/hex/solver/constraints/union.ex | 2 +- lib/hex/solver/constraints/util.ex | 2 +- lib/hex/solver/constraints/version.ex | 2 +- lib/hex/solver/failure.ex | 2 +- lib/hex/solver/incompatibility.ex | 8 ++++---- lib/hex/solver/package_lister.ex | 2 +- lib/hex/solver/package_range.ex | 4 ++-- lib/hex/solver/partial_solution.ex | 2 +- lib/hex/solver/registry.ex | 2 +- lib/hex/solver/requirement.ex | 2 +- lib/hex/solver/solver.ex | 2 +- lib/hex/solver/term.ex | 2 +- lib/hex/solver/util.ex | 2 +- test/hex/solver_test.exs | 8 ++++---- 20 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/hex/solver.ex b/lib/hex/solver.ex index dbd00aad..a277940b 100644 --- a/lib/hex/solver.ex +++ b/lib/hex/solver.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver do _ = """ @@ -51,8 +51,12 @@ defmodule Hex.Solver do {:ok, result()} | {:error, String.t()} def run(registry, dependencies, locked, overrides, opts \\ []) do case Solver.run(registry, dependencies, locked, overrides) do - {:ok, solution} -> {:ok, Map.drop(solution, ["$root", "$lock"])} - {:error, incompatibility} -> {:error, Failure.write(incompatibility, opts)} + {:ok, solution} -> + {:ok, Map.drop(solution, ["$root", "$lock"])} + + {:error, incompatibility} -> + IO.inspect(incompatibility) + {:error, Failure.write(incompatibility, opts)} end end diff --git a/lib/hex/solver/assignment.ex b/lib/hex/solver/assignment.ex index 55f0e385..0c57f726 100644 --- a/lib/hex/solver/assignment.ex +++ b/lib/hex/solver/assignment.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Assignment do @moduledoc false diff --git a/lib/hex/solver/constraint.ex b/lib/hex/solver/constraint.ex index c6717a87..67722a79 100644 --- a/lib/hex/solver/constraint.ex +++ b/lib/hex/solver/constraint.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defprotocol Hex.Solver.Constraint do @moduledoc false diff --git a/lib/hex/solver/constraints/empty.ex b/lib/hex/solver/constraints/empty.ex index 18befa3c..91e6dadf 100644 --- a/lib/hex/solver/constraints/empty.ex +++ b/lib/hex/solver/constraints/empty.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Empty do @moduledoc false diff --git a/lib/hex/solver/constraints/impl.ex b/lib/hex/solver/constraints/impl.ex index bb3ac152..d40ff621 100644 --- a/lib/hex/solver/constraints/impl.ex +++ b/lib/hex/solver/constraints/impl.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Impl do @moduledoc false diff --git a/lib/hex/solver/constraints/range.ex b/lib/hex/solver/constraints/range.ex index a55881a7..03516ae4 100644 --- a/lib/hex/solver/constraints/range.ex +++ b/lib/hex/solver/constraints/range.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Range do @moduledoc false diff --git a/lib/hex/solver/constraints/union.ex b/lib/hex/solver/constraints/union.ex index f028c97e..06564447 100644 --- a/lib/hex/solver/constraints/union.ex +++ b/lib/hex/solver/constraints/union.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Union do @moduledoc false diff --git a/lib/hex/solver/constraints/util.ex b/lib/hex/solver/constraints/util.ex index aea14cbb..723877ec 100644 --- a/lib/hex/solver/constraints/util.ex +++ b/lib/hex/solver/constraints/util.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Util do @moduledoc false diff --git a/lib/hex/solver/constraints/version.ex b/lib/hex/solver/constraints/version.ex index a3559c28..ba12a754 100644 --- a/lib/hex/solver/constraints/version.ex +++ b/lib/hex/solver/constraints/version.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Constraints.Version do @moduledoc false diff --git a/lib/hex/solver/failure.ex b/lib/hex/solver/failure.ex index 2625dc90..372a7e69 100644 --- a/lib/hex/solver/failure.ex +++ b/lib/hex/solver/failure.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Failure do @moduledoc false diff --git a/lib/hex/solver/incompatibility.ex b/lib/hex/solver/incompatibility.ex index 43aa0cbd..a8719871 100644 --- a/lib/hex/solver/incompatibility.ex +++ b/lib/hex/solver/incompatibility.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Incompatibility do @moduledoc false @@ -59,7 +59,7 @@ defmodule Hex.Solver.Incompatibility do }, opts ) do - "\"lock\" specifies #{bright_term_abs(dependee, opts)}" + "\"the lock\" specifies #{bright_term_abs(dependee, opts)}" end def to_string( @@ -379,7 +379,7 @@ defmodule Hex.Solver.Incompatibility do do: bright("your app", opts) defp package_name(%Term{package_range: %PackageRange{name: "$lock"}}, opts), - do: bright("lock", opts) + do: bright("the lock", opts) defp package_name(%Term{package_range: %PackageRange{repo: nil, name: name}}, opts), do: bright(name, opts) @@ -399,7 +399,7 @@ defmodule Hex.Solver.Incompatibility do do: bright("your app", opts) defp terse_every(%Term{package_range: %PackageRange{name: "$lock"}}, opts), - do: bright("lock", opts) + do: bright("the lock", opts) defp terse_every(term, opts) do if Constraint.any?(term.package_range.constraint) do diff --git a/lib/hex/solver/package_lister.ex b/lib/hex/solver/package_lister.ex index 039fee08..eb362fb6 100644 --- a/lib/hex/solver/package_lister.ex +++ b/lib/hex/solver/package_lister.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.PackageLister do @moduledoc false diff --git a/lib/hex/solver/package_range.ex b/lib/hex/solver/package_range.ex index dd3782d8..21d6d797 100644 --- a/lib/hex/solver/package_range.ex +++ b/lib/hex/solver/package_range.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.PackageRange do @moduledoc false @@ -11,7 +11,7 @@ defmodule Hex.Solver.PackageRange do constraint: nil def to_string(%PackageRange{name: "$root"}), do: "your app" - def to_string(%PackageRange{name: "$lock"}), do: "lock" + def to_string(%PackageRange{name: "$lock"}), do: "the lock" def to_string(%PackageRange{repo: nil, name: name, constraint: constraint}), do: "#{name}#{constraint(constraint)}" diff --git a/lib/hex/solver/partial_solution.ex b/lib/hex/solver/partial_solution.ex index a0183981..08795c66 100644 --- a/lib/hex/solver/partial_solution.ex +++ b/lib/hex/solver/partial_solution.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.PartialSolution do @moduledoc false diff --git a/lib/hex/solver/registry.ex b/lib/hex/solver/registry.ex index b2c893a1..83581cd8 100644 --- a/lib/hex/solver/registry.ex +++ b/lib/hex/solver/registry.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Registry do _ = """ diff --git a/lib/hex/solver/requirement.ex b/lib/hex/solver/requirement.ex index 5ac84e5a..0c862ed2 100644 --- a/lib/hex/solver/requirement.ex +++ b/lib/hex/solver/requirement.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Requirement do @moduledoc false diff --git a/lib/hex/solver/solver.ex b/lib/hex/solver/solver.ex index 17c23d49..c950f88a 100644 --- a/lib/hex/solver/solver.ex +++ b/lib/hex/solver/solver.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Solver do @moduledoc false diff --git a/lib/hex/solver/term.ex b/lib/hex/solver/term.ex index eddd74dd..6d1a8abd 100644 --- a/lib/hex/solver/term.ex +++ b/lib/hex/solver/term.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Term do @moduledoc false diff --git a/lib/hex/solver/util.ex b/lib/hex/solver/util.ex index 2b29fd15..c1dd1db5 100644 --- a/lib/hex/solver/util.ex +++ b/lib/hex/solver/util.ex @@ -1,4 +1,4 @@ -# Vendored from hex_solver v0.2.0 (c71c22f), do not edit manually +# Vendored from hex_solver v0.2.0 (b0424d1), do not edit manually defmodule Hex.Solver.Util do @moduledoc false diff --git a/test/hex/solver_test.exs b/test/hex/solver_test.exs index cfe39d34..53623cb3 100644 --- a/test/hex/solver_test.exs +++ b/test/hex/solver_test.exs @@ -130,14 +130,14 @@ defmodule Hex.SolverTest do test "failure due to locked dep" do assert solve([ex_plex: "0.1.0", decimal: nil], decimal: "0.0.1") == """ - Because "lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0". - And because "your app" depends on "lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden. + Because "the lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "the lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0". + And because "your app" depends on "the lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden. So, because "your app" depends on "ex_plex 0.1.0", version solving failed.\ """ assert solve([decimal: nil, ex_plex: "0.1.0"], decimal: "0.0.1") == """ - Because "lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0". - And because "your app" depends on "lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden. + Because "the lock" specifies "decimal 0.0.1" and "ex_plex >= 0.1.0 and < 0.2.0" depends on "decimal ~> 0.1.0", "the lock" is incompatible with "ex_plex >= 0.1.0 and < 0.2.0". + And because "your app" depends on "the lock", "ex_plex >= 0.1.0 and < 0.2.0" is forbidden. So, because "your app" depends on "ex_plex 0.1.0", version solving failed.\ """