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

Puppet + puppet-rvm + bundler defaults to system Ruby, not RVM default #33

Closed
ericqweinstein opened this issue Apr 8, 2014 · 2 comments

Comments

@ericqweinstein
Copy link

I'm running a CentOS 6.5 VM with Puppet + puppet-rvm. System Ruby is 1.8.7, but I'm using 1.9.3p545 (RVM default) via the module. On the Puppet master:

class project (
  # Hiera magicks
) {
  include rvm

  rvm_system_ruby {
    'ruby-1.9.3-p545':
      ensure      => present,
      default_use => true,
  } ->
  exec { 'load RVM as a function':
    user    => root,
    cwd     => '/usr/local/rvm',
    command => '/bin/sh -c "source scripts/rvm"',
  } ->
  exec { 'check Ruby version':
    user      => root,
    command   => '/bin/echo "$RUBY_VERSION"',
    logoutput => true,
  } ->
  exec { 'install Ruby dependencies':
    user      => root,
    path      => '/path/to/bundler',
    cwd       => '/my/ruby/project',
    command   => 'bundle install',
    logoutput => true,
  }
}

When I run puppet agent -t on the agent, I get the following error:

Notice: /Stage[main]/Project/Exec[load RVM as a function]/returns: executed successfully
Notice: /Stage[main]/Project/Exec[check Ruby version]/returns: ruby-1.9.3-p545
Notice: /Stage[main]/Project/Exec[check Ruby version]/returns: executed successfully
Notice: /Stage[main]/Project/Exec[install Ruby dependencies]/returns: Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3
Error: bundle install returned 18 instead of one of [0]
Error: /Stage[main]/Project/Exec[install Ruby dependencies]/returns: change from notrun to 0 failed: bundle install returned 18 instead of one of [0]

I checked the Bundler source, and error code 18 is associated with the version mismatch. I haven't been able to figure out why Puppet reports using 1.9.3 via RVM, but then defaults to the system 1.8.7. Any ideas?

@carlossg
Copy link
Member

because the commands in exec's are running in separate shells, you'd need to execute rvm ruby-1.9.3-p545 do bundle install

@ericqweinstein
Copy link
Author

I thought it might have been running in a different shell. Works like a charm—thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants