From 11e775b03b200f3d9899edfb9c994ede42adfd46 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 30 Sep 2010 01:39:05 -0700 Subject: [PATCH] Retry on TypeError for NFS cleanup, which seems to happen during Kernel#system --- lib/vagrant/hosts/bsd.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/hosts/bsd.rb b/lib/vagrant/hosts/bsd.rb index 9bf3f2310..ef465fae1 100644 --- a/lib/vagrant/hosts/bsd.rb +++ b/lib/vagrant/hosts/bsd.rb @@ -35,12 +35,15 @@ module Vagrant def nfs_cleanup return if !File.exist?("/etc/exports") - system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1") - if $?.to_i == 0 - # Use sed to just strip out the block of code which was inserted - # by Vagrant - system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports") + retryable(:tries => 10, :on => TypeError) do + system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1") + + if $?.to_i == 0 + # Use sed to just strip out the block of code which was inserted + # by Vagrant + system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports") + end end end end