diff --git a/lib/vagrant-cachier/bucket/apt_cacher.rb b/lib/vagrant-cachier/bucket/apt_cacher.rb index de71661..4dfce7d 100644 --- a/lib/vagrant-cachier/bucket/apt_cacher.rb +++ b/lib/vagrant-cachier/bucket/apt_cacher.rb @@ -12,17 +12,21 @@ module VagrantPlugins guest = machine.guest if guest.capability?(:apt_cacher_dir) - guest_path = guest.capability(:apt_cacher_dir) + if machine.config.cache.enable_nfs + guest_path = guest.capability(:apt_cacher_dir) - @env[:cache_dirs] << guest_path + @env[:cache_dirs] << guest_path - machine.communicate.tap do |comm| - comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}") - unless comm.test("test -L #{guest_path}") - comm.sudo("rm -rf #{guest_path}") - comm.sudo("mkdir -p `dirname #{guest_path}`") - comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}") + machine.communicate.tap do |comm| + comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}") + unless comm.test("test -L #{guest_path}") + comm.sudo("rm -rf #{guest_path}") + comm.sudo("mkdir -p `dirname #{guest_path}`") + comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}") + end end + else + @env[:ui].info I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher') end else @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-cacher') diff --git a/locales/en.yml b/locales/en.yml index b8147ad..8badb39 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -6,6 +6,9 @@ en: Skipping %{bucket} cache bucket as the guest machine does not support it unknown_cache_scope: |- Unknown cache scope '%{cache_scope}' (allowed scopes: %{allowed}) + nfs_required: |- + The '%{bucket}' cache bucket requires NFS to be enabled, please add + `config.cache.enable_nfs = true` to your Vagrantfile. will_fix_machine_cache_dir: |- A vagrant-cachier provider specific cache dir was found under '%{current_path}' and it will be moved to