'How does one install a gem that a chef library (not a recipe) requires?

I have a cookbook foo that provides functionality as a library (and has no recipes). This functionality requires rest-client (which used to be built-in to earlier Chef versions, but was removed). The obvious answer is to add a gem 'rest-client' to the cookbook metadata, but this breaks berks vendor because rest-client is not installed and it seemingly cannot install it, either. The other obvious answer is to add a chef_gem incantation immediately before require 'rest-client', but since it's a library and not a recipe chef_gem isn't callable. How can I ensure that foo gets rest-client installed before its library is compiled without putting it in the cookbook metadata?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source