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.
This commit is contained in:
Seth Vargo 2016-06-25 17:18:32 -04:00
parent c4a0a86ee0
commit 3b2ffae400
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
4 changed files with 44 additions and 0 deletions

View File

@ -784,6 +784,10 @@ module Vagrant
error_key(:virtualbox_mount_failed) error_key(:virtualbox_mount_failed)
end end
class VirtualBoxMountNotSupportedBSD < VagrantError
error_key(:virtualbox_mount_not_supported_bsd)
end
class VirtualBoxNameExists < VagrantError class VirtualBoxNameExists < VagrantError
error_key(:virtualbox_name_exists) error_key(:virtualbox_name_exists)
end end

View File

@ -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

View File

@ -26,6 +26,11 @@ module VagrantPlugins
Cap::NFS Cap::NFS
end end
guest_capability(:bsd, :mount_virtualbox_shared_folder) do
require_relative "cap/virtualbox"
Cap::VirtualBox
end
guest_capability(:bsd, :remove_public_key) do guest_capability(:bsd, :remove_public_key) do
require_relative "cap/public_key" require_relative "cap/public_key"
Cap::PublicKey Cap::PublicKey

View File

@ -1355,6 +1355,25 @@ en:
The error output from the command was: The error output from the command was:
%{output} %{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: |- virtualbox_name_exists: |-
The name of your virtual machine couldn't be set because VirtualBox The name of your virtual machine couldn't be set because VirtualBox
is reporting another VM with that name already exists. Most of the is reporting another VM with that name already exists. Most of the