Skip to Content

Pessimistic Version Contraint

Posted on

Pessimistic Version Constraint

Language (Tool) Syntax Example Interprets As Notes
Ruby (Bundler) ~> 1.2.3 >= 1.2.3 and < 1.3.0 Only patch updates allowed
~> 1.2 >= 1.2.0 and < 2.0.0 Minor & patch updates allowed
~> 0.2.3 >= 0.2.3 and < 0.3.0 In pre-1.0, minor is treated as breaking
Node.js (npm/yarn) ~1.2.3 >= 1.2.3 and < 1.3.0 Similar to Ruby’s ~>
^1.2.3 >= 1.2.3 and < 2.0.0 Allows minor & patch updates (more open than ~>)
^0.2.3 >= 0.2.3 and < 0.3.0 Special rule for 0.x versions
Python (pip) ~= 1.2.3 >= 1.2.3 and < 1.3.0 Introduced in PEP 440
PHP (Composer) ~1.2.3 >= 1.2.3 and < 1.3.0 Pessimistic constraint like Ruby
Elixir (Mix) ~> 1.2.3 >= 1.2.3 and < 1.3.0 Same semantics as Ruby
Rust (Cargo) ^1.2.3 >= 1.2.3 and < 2.0.0 Follows SemVer, major version fixed
Go (go.mod) >= 1.2.3 No pessimistic operator Uses minimal version selection

References

comments powered by Disqus