Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

versions in elixir dependencies

What is the difference between declaring a dependency to a package using this syntax: "==1.2.3" (which I understand, it is clearly explained in the spec), and just "1.2.3" (which I also see being used, but it is not explained in the script) ? Is this like a soft constraint, that gives the package manager some freedom to resolve to another version?

Thanks

like image 668
jens Avatar asked Oct 20 '25 01:10

jens


2 Answers

A dependency might by specified as:

  • "== 1.2.3" effectively the same as "1.2.3", meaning “exactly this version”
  • ">= 1.2.3", meaning “any version greater or equal that that, including major versions updates”
  • "<= 1.2.3", meaning “any version that is not greater that that”
  • "~> 1.2.3", meaning “same major version, same minor version with any subversion greater or equal than 3
  • "~> 1.2", meaning “same major version, with any minor version greater or equal than 2

The syntax "~> 1" is disallowed, because it’s effectively the same as ">= 1.0.0".

So, to have some flexibility people usually do "~> 1.2.3" or "~> 1.2" if they trust the package using proper semantic versioning. ">= 1.2.3" is not advised because even with semantic versioning major versions might contain breaking changes.

like image 162
Aleksei Matiushkin Avatar answered Oct 22 '25 04:10

Aleksei Matiushkin


I believe "1.2.3" is equal to "==1.2.3", which I have never seen been used. But I can't support it with reference unfortunately. But it always behaves like exact match.

UPDATE Yup, look here: https://github.com/elixir-lang/elixir/blob/f47792547b72ee3043da7205a50e4a1fca2a93dd/lib/elixir/test/elixir/version_test.exs#L52

like image 41
Ivan Yurov Avatar answered Oct 22 '25 04:10

Ivan Yurov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!