Semantic versioning constraints
• 124 words • 1 min • updated
⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
When working with semantic versioning a.k.a. semver, it’s often useful to use range constraints1 to express the versions you’re interested in.
The most useful ones are the tilde (~) and the circumflex / hat / caret
(^)2:
~4.2.1: picks up4.2.xforx >= 1^5.0.2: picks up5.x.yforx >= 0andy >= 2
Popular software tooling that uses them include:
- nodejs / npm packages
- terraform
- ruby gems (here
~>is used instead of simply~)
Sometimes I use https://jubianchi.github.io/semver-check to double-check3, or to teach teammates how the range constraints work.