On the original issue
I get the message about on vagrant up, saying the id values aren't the
same as when I created. (503 vs 501 in general)
you can fix it by editing your UID in the following file .vagrant\machines\default\virtualbox\creator_uid
and changing the 501/503 to a 0. (0 means you run as sudo)
But I think another issue that will pop up is that each of your machines is creating its own VM and stores it under your /Users/user/Documents/Virtual Machines
and you're not sharing those files.
when you create a VM using VirtualBox, vb will assign the VM and id - this id is key and will make the link between vagrant and vb. As you create 2 different VMs, the VM have different Id and vagrant is not able to switch between the 2.
Hope this is clear so far, but how to go from there - you would have couple of options:
apparently you don't mind much about the content of the VM (as you do rm -rf
so you recreate the VM each time you switch computer) so you can create a .vagrant.home
and .vagrant.office
and switch the .vagrant
to point to the corresponding folder when you change machine so at least you don't need to recreate the VM, you can just start the VM from the corresponding computer. This is not ideal but will work.
you can avoid switching the .vagrant
directory from above points by setting the env variable VAGRANT_CWD so you will not store the .vagrant
directory under your dropbox account but you can have a script that export this variable and store the .vagrant directory separately on each of your machine (a folder that is not shared) so each machine will create its own VM.
You can have the VAGRANT_CWD
set in your bash profile for each computer if you plan to have a different location, but you can also have for example a workhere.sh
script that will just do export VAGRANT_CWD=/folder...
if you have the same settings on both computer and just do source workhere
before you do vagrant up
the other option (I did not test) will involve a few steps: export/import the VM once created from VirtualBox into one computer to another. The issue here will be to keep Id. I am not sure but normally virtual box should keep the Id when you import into the other computer.
- you can check the file under
/Users/<user>/Library/VirtualBox/VirtualBox.xml
and review the entry under <MachineRegistry>
, you will get the uuid of the machine entry, make sure they match between your 2 computers after you export/import
- for vagrant there is another file you need to sync between your 2 computer
/Users/<user>/.vagrant.d/data/machine-index/index
which list of available VM on the computer. If you have other VM on one computer not available on this other, it would be ok to sync but best is to copy only the necessary entry for the VM you want to sync.
After you've done this and you sync the .vagrant
folder, you should be able to vagrant up
from one computer or the other.
Again, I did not test all the steps but I assume this would work.
Few notes:
- this will work only if the 2 computers have the same settings (same OS (if not version at least same family), folder structure as some files involve full path, same virtual box version ...)
- vagrant box should be in sync on the 2 computers (but I assume this is the case as you can vagrant up from same Vagrantfile)
- if you destroy/create the VM on any of the computer, you will need to sync again the Id as virtual box will assign a new Id each time you create a new VM