Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the ruby name as the definition to install #36

Merged
merged 1 commit into from
Mar 3, 2014
Merged

Use the ruby name as the definition to install #36

merged 1 commit into from
Mar 3, 2014

Conversation

gsandie
Copy link
Contributor

@gsandie gsandie commented Feb 28, 2013

The docs show that you can pass in a hash containing the ruby name and some environment settings, to get the ruby built with those settings. However when running ruby user install and passing in environment settings the chef run would fail.

Given the json:

"rbenv": {
    "create_profiled": false,
    "user_installs": [
      {
        "user": "gavin",
        "rubies": [
          {
            "name": "1.9.3-p385", "environment": { "CC": "gcc" }
          }
        ],
        "global": "1.9.3-p385",
        "gems": {
          "1.9.3-p385": [
            { "name": "bundler" }
          ]
        }
      }
    ]
  }

The chef run would fail with:

================================================================================
Recipe Compile Error in /tmp/chef/cookbooks/rbenv/recipes/user.rb
================================================================================


Chef::Exceptions::ValidationFailed
----------------------------------
Option definition must be a kind of String!  You passed {"name"=>"1.9.3-p385", "environmment"=>{"CC"=>"gcc"}}.


Cookbook Trace:
---------------
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:29:in `block (3 levels) in from_file'
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:28:in `block (2 levels) in from_file'
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:26:in `each'
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:26:in `block in from_file'
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:22:in `each'
  /tmp/chef/cookbooks/rbenv/recipes/user.rb:22:in `from_file'


Relevant File Content:
----------------------
/tmp/chef/cookbooks/rbenv/recipes/user.rb:

 22:  Array(node['rbenv']['user_installs']).each do |rbenv_user|
 23:    rubies    = rbenv_user['rubies'] || node['rbenv']['user_rubies']
 24:    gem_hash  = rbenv_user['gems'] || node['rbenv']['user_gems']
 25:  
 26:    rubies.each do |rubie|
 27:      if rubie.is_a?(Hash)
 28:        rbenv_ruby "#{rubie} (#{rbenv_user['user']})" do
 29>>         definition  rubie
 30:          user        rbenv_user['user']
 31:          root_path   rbenv_user['root_path'] if rbenv_user['root_path']
 32:          environment rubie['environment'] if rubie['environment']
 33:        end
 34:      else
 35:        rbenv_ruby "#{rubie} (#{rbenv_user['user']})" do
 36:          definition  rubie
 37:          user        rbenv_user['user']
 38:          root_path   rbenv_user['root_path'] if rbenv_user['root_path']

This change ensures that the name key in the hash is used as the definition.

@jasherai
Copy link
Contributor

jasherai commented May 2, 2013

Oh blimey! Sorry that was my bad.

👍 for this fix!

@sds
Copy link
Contributor

sds commented Jan 17, 2014

Any specific reason this never got merged?

@jyotty jyotty mentioned this pull request Feb 14, 2014
@fnichol
Copy link
Contributor

fnichol commented Mar 3, 2014

Super late here, but thank you!!

@gsandie
Copy link
Contributor Author

gsandie commented Mar 3, 2014

No worries. Thanks for the cookbook :)

Gavin

On 3 Mar 2014, at 03:24, Fletcher Nichol [email protected] wrote:

Super late here, but thank you!!


Reply to this email directly or view it on GitHub.

@lock
Copy link

lock bot commented May 31, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants