From 3b2ffae400700c8046a554d7bf1539ef5f546db5 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sat, 25 Jun 2016 17:18:32 -0400 Subject: [PATCH] guests/bsd: Print a very descriptive error when mounting vbox folders BSD-based guests do not support VirtualBox shared folders. This is a common source of confusion in Vagrant. This new error clearly explains that this is not a bug in Vagrant and provides instructions on how to disable them. --- lib/vagrant/errors.rb | 4 ++++ plugins/guests/bsd/cap/virtualbox.rb | 16 ++++++++++++++++ plugins/guests/bsd/plugin.rb | 5 +++++ templates/locales/en.yml | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 plugins/guests/bsd/cap/virtualbox.rb diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 786e52f33..a557f88d8 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -784,6 +784,10 @@ module Vagrant error_key(:virtualbox_mount_failed) end + class VirtualBoxMountNotSupportedBSD < VagrantError + error_key(:virtualbox_mount_not_supported_bsd) + end + class VirtualBoxNameExists < VagrantError error_key(:virtualbox_name_exists) end diff --git a/plugins/guests/bsd/cap/virtualbox.rb b/plugins/guests/bsd/cap/virtualbox.rb new file mode 100644 index 000000000..14406c534 --- /dev/null +++ b/plugins/guests/bsd/cap/virtualbox.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module GuestBSD + module Cap + class VirtualBox + # BSD-based guests do not currently support VirtualBox synced folders. + # Instead of raising an error about a missing capability, this defines + # the capability and then provides a more detailed error message, + # linking to sources on the Internet where the problem is + # better-described. + def self.mount_virtualbox_shared_folder(machine, name, guestpath, options) + raise Vagrant::Errors::VirtualBoxMountNotSupportedBSD + end + end + end + end +end diff --git a/plugins/guests/bsd/plugin.rb b/plugins/guests/bsd/plugin.rb index c83a3a454..368765cdf 100644 --- a/plugins/guests/bsd/plugin.rb +++ b/plugins/guests/bsd/plugin.rb @@ -26,6 +26,11 @@ module VagrantPlugins Cap::NFS end + guest_capability(:bsd, :mount_virtualbox_shared_folder) do + require_relative "cap/virtualbox" + Cap::VirtualBox + end + guest_capability(:bsd, :remove_public_key) do require_relative "cap/public_key" Cap::PublicKey diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 249206838..61cee6032 100755 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1355,6 +1355,25 @@ en: The error output from the command was: %{output} + virtualbox_mount_not_supported_bsd: |- + Vagrant is not able to mount VirtualBox shared folders on BSD-based + guests. BSD-based guests do not support the VirtualBox filesystem at + this time. + + To change the type of the default synced folder, specify the type as + rsync or nfs: + + config.vm.synced_folder ".", "/vagrant", type: "nfs" # or "rsync" + + Alternatively, if you do not need to mount the default synced folder, + you can also disable it entirely: + + config.vm.synced_folder ".", "/vagrant", disabled: true + + You can read more about Vagrant's synced folder types and the various + configuration options on the Vagrant website. + + This is not a bug in Vagrant. virtualbox_name_exists: |- The name of your virtual machine couldn't be set because VirtualBox is reporting another VM with that name already exists. Most of the