Chef中无Recipe的ruby_rbenv Cookbook如何加入Runlist并使用?
ruby_rbenv Cookbook Hey there! Let's figure out why you're hitting those missing recipe errors and how to get ruby_rbenv working correctly in your Chef setup.
Why You're Seeing These Errors
The ruby_rbenv cookbook has shifted away from traditional recipes to using Chef's custom resources—this is a modern Chef best practice that makes configurations more flexible and reusable. That's why you won't find a recipes/ directory in its source code anymore, and old recipe references like ruby_rbenv::system_install or the default ruby_rbenv recipe don't exist.
How to Use ruby_rbenv Correctly
Instead of adding recipes to your runlist, you'll call the cookbook's custom resources directly from your own cookbook's recipes. Here's a step-by-step breakdown:
Add the Dependency First
Make sure your cookbook'smetadata.rbdeclares a dependency onruby_rbenv:depends 'ruby_rbenv'Install System-Level rbenv
To set up rbenv for all system users, use therbenv_system_installresource in your recipe:rbenv_system_install 'system-wide rbenv' do user 'root' # Specify the user owning the system rbenv installation endInstall User-Level rbenv
For a specific user (like an app deploy user), use therbenv_user_installresource:rbenv_user_install 'deploy-user rbenv' do user 'deploy' # Target user for the rbenv installation endInstall Ruby Versions & Set Global Default
Once rbenv is installed, use therbenv_rubyandrbenv_globalresources to manage Ruby versions:# Install a specific Ruby version for the deploy user rbenv_ruby '3.2.2' do user 'deploy' end # Set that version as the global default for the user rbenv_global '3.2.2' do user 'deploy' end
Key Notes
- Never add
ruby_rbenvorruby_rbenv::system_installdirectly to your runlist—these recipe paths no longer exist. - Check the
README.mdfile included with theruby_rbenvcookbook for a full list of custom resources, available parameters, and advanced configurations (like setting custom installation paths or using specific rbenv plugins).
内容的提问来源于stack exchange,提问作者Abhilash

