How do I check if Chef's version mets a gem requirement from inside a recipe?
Chef::Version contains the version number of the Chef gem, and I want to check that it meets the gem requirement of ~> 10.14 inside a recipe. Alternatively, you can use Chef’s built-in version comparison mechanisms (available since at least Chef 12): Chef::VersionConstraint.new('>= 14.0.0').include? Chef::VERSION Use Gem::Requirement and Gem::Version : Gem::Requirement.new("~> 10.14").satisfied_by?(Gem::Version.new(Chef::VERSION)) This returns a boolean value - true if Chef::VERSION satisfies ~> 10.14 . 来源: https://stackoverflow.com/questions/19516077/how-do-i-check-if-chefs-version-mets-a-gem