Why do MIX dependencies have a “~>” before the semantic version of the dependency?

In mix.exsyou can declare dependencies, for example:

def deps do
  [{:plug, "~> 1.0"}]
end

Why do you need "~>" instead of just the version on the second part of the tuple.

I saw that if it gets a dependency on git, you can write a dependency, for example:

def deps do
  [{:plug, git: "git://github.com/elixir-lang/plug.git"}]
end
+4
source share
1 answer

This fantastic arrow is supported by Version . It rounds your dependency with the precision given by a digit, which is the leftmost adjacent most specific.

Example:

~> 2.0.0 

means

get the version between 2.0.0 and 2.1.0 because it is 0 in the center - this is the left neighbor of the most specific.

Check out more examples in the module Version.

, , mix deps.upgrade, - , ..

+4

Source: https://habr.com/ru/post/1689574/


All Articles