'How to specify a provider during `vagrant up` command?
I have two machines (linux, Mac) and need to use vagrant to manage the vm. VirtualBox is used in the Liux while parallels is used in Mac. so I configured these two providers in the vagrant config file as below:
Vagrant.configure('2') do |config|
config.ssh.forward_agent = true
config.ssh.password = 'crunch'
config.vm.box = 'ubuntu/xenial64'
config.vm.provider 'virtualbox' do |vb|
vb.gui = true
vb.memory = '8192'
vb.name = 'ubuntu'
end
config.vm.provider 'parallels' do |vb|
vb.gui = true
vb.memory = '8192'
vb.name = 'ubuntu'
config.vm.box = 'parallels/ubuntu-14.04'
end
on my mac system, when I run below command but got an error:
$ vagrant up --provider parallels
An active machine was found with a different provider. Vagrant
currently allows each machine to be brought up with only a single
provider at a time. A future version will remove this limitation.
Until then, please destroy the existing machine to up with a new
provider.
Machine name: default
Active provider: virtualbox
Requested provider: parallels
I have installed the required providers:
$ vagrant plugin list
docker (0.4.0)
vagrant-parallels (1.7.8)
vagrant-share (1.1.9, system)
vagrant-vbguest (0.15.0)
so why vagrant
doesn't pick up the --provider
parameter?
Solution 1:[1]
This is a current limitation of vagrant
you cannot back the same machine with both VirtualBox and VMware Fusion. This is a limitation that will be removed in a future version of Vagrant.
I am not sure if it will get ever solved by vagrant. but so you have created your machine once with virtualbox so now it is expected you work with this VM, not with another machine.
One way to fix this is to backup the .vagrant
folder with the reference of the existing VM like (.vagrant.vbox
) and re-run vagrant up --provider parallels
to let it create the parallels VM.
If you want to switch back to the virtualbox VM, you can backup the newly created .vagrant
folder and rename the .vagrant.vbox
as .vagrant
Solution 2:[2]
Short answer
Remove the .vagrant
folder in the project.
rm -r .vagrant
(I leave this duplicated answer because I personally was too lazy to read the previous one and missed the solution)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Frederic Henri |
Solution 2 | ADR |