Reputation: 11293
I've been running into issues when trying to run the rvm::user
recipe from fnichol/chef-rvm. I'm using chef along with a Vagrant box. rvm installs fine, but every time chef tries to install a ruby, it fails with this error:
WARN: Failed to install rvm_ruby[ruby-1.9.3-p448]. Check logs in /log/ruby-1.9.3-p448
Here's my Vagrantfile
:
Vagrant.configure("2") do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::user"
chef.json = {
:rvm => {
:user_installs => [
{
:user => "vagrant",
:default_ruby => "1.9.3",
:rubies => ["1.9.3"],
:global_gems => [
{ :name => 'bundler' }
],
}
]
}
end
end
1.2.7
precise32
1.22.11
59dc482
Upvotes: 2
Views: 2390
Reputation: 11721
My setup was much more complicated, however the error was the same. Ultimately i found that adding the apt chef recipe fixed everything.
chef.add_recipe "apt"
chef.add_recipe "rvm::vagrant"
chef.add_recipe "rvm::user"
> Run List is [recipe[apt], recipe[curl], recipe[rvm::vagrant], recipe[rvm::user]]
Adding the line
vagrant ALL=(ALL:ALL) NOPASSWD: ALL
didn't work for my scenario.
I believe the apt chef recipe runs apt update which fixes an issue with old and ill matched versions.
The error messages i received were
Error executing action `install` on resource 'package[libxml2-dev]'
apt-get -q -y install libxml2-dev=2.7.8.dfsg-5.1ubuntu4.1 returned 100, expected 0
....
Error executing action `install` on resource 'rvm_ruby[2.1.1]'
Upvotes: 0
Reputation: 11293
It turns out that Vagrant was running chef in a non-interactive/non-tty session. The sudo
command doesn't like to run in non-interactive sessions, and causes rvm to fail when it tries install dependencies (via apt-get in ubuntu).
You can allow sudo to run non-interactively by adding this to /etc/sudoers
:
vagrant ALL= (ALL:ALL) NOPASSWD: ALL
Once I added this, chef installed the rvm::user
recipe successfully.
Upvotes: 3