Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make .vagrant tree host-specific #3362

Closed
odigity opened this issue Mar 31, 2014 · 7 comments
Closed

Make .vagrant tree host-specific #3362

odigity opened this issue Mar 31, 2014 · 7 comments

Comments

@odigity
Copy link
Contributor

odigity commented Mar 31, 2014

I keep my local repos in a Dropbox folder so I can switch between my desktop and laptop seamlessly and still have the current state of everything be synced, including changes that haven't been committed yet. The problem is the .vagrant tree is not host-specific, so when I've brought vagrant up on one host, then do the same on a second host, the second host overwrites the .vagrant/machines/[name]/virtualbox/id file which breaks the original host.

I did find a blog post describing the problem and a solution:

http://www.binaryphile.com/vagrant/sharing-vagrant-project-files-over-dropbox/

It's a little outdated (there's no more Virtualbox.xml anymore), but was still useful enough to help me understand the problem. However, the described solution (manually changing the UUID on the second host to match the first) is very brittle.

I propose adding an additional directory layer to the .vagrant tree to include the host name, so the same tree can support different VM UUIDs on different hosts off the same Vagrantfile. In order words, this:

.vagrant/machines/[name]/virtualbox/id

Would instead become one of the following (take your pick):

  • .vagrant/[host]/machines/[name]/virtualbox/id
  • .vagrant/machines/[host]/[name]/virtualbox/id
  • .vagrant/machines/[name]/[host]/virtualbox/id
  • .vagrant/machines/[name]/virtualbox/[host]/id
  • .vagrant/machines/[name]/virtualbox/[host]-id

The last option has the merit of not adding another level of directory structure.

@mitchellh
Copy link
Contributor

I can see the utility, but it is also quite easy to set a different VAGRANT_DOTFILE_PATH per project (using a .env file or something). I'm imaging adding the hostname/username to the local path and I'm seeing so many edge cases that VirtualBox/VMware wouldn't like. I think using a different dotfile path would simplify things for now.

If this is an ongoing pain point for many more people. I'll look into it further. But since there is a viable workaround, it is fairly low priority.

@odigity
Copy link
Contributor Author

odigity commented Mar 31, 2014

I didn't know VAGRANT_DOTFILE_PATH exists. That's certainly a practical solution. I searched the Issues list for "Dropbox" but didn't find anything relevant. Searching for "VAGRANT_DOTFILE_PATH" did land me on issues discussing the Dropbox scenario, though.

Do you want me to add it to the docs? Not currently included:

http://docs.vagrantup.com/v2/other/environmental-variables.html

FYI-For other uses with the same problem who stumble upon this issue, here's what I did:

(on my laptop -- Ubuntu 13.10)

  1. vagrant halt to shutdown machines
  2. added "export VAGRANT_DOTFILE_PATH=.vagrant-laptop" to ~/.bashrc
  3. open new terminals to inherit the new env var
  4. move .vagrant to .vagrant-laptop
  5. vagrant up -- it works!
  6. change "/.vagrant" to "/.vagrant*" in my .gitignore

When I get home, I am going to either leave my desktop with the default, or change it to .vagrant-desktop.

@awdng
Copy link

awdng commented Apr 17, 2014

This is awesome! That has been a big pain point for me when working with vagrant on different machines (work/home/laptop) and syncing with dropbox. Thanks!

@simspace-dev
Copy link

Thank you! Thank you! Thank you!

@simkessy
Copy link

How do you set this for Windows?

@golfhotel
Copy link

Can you explain how to manage and configure VAGRANT_DOTFILE_PATH on Windows host?
Best regards.

@NeMO84
Copy link

NeMO84 commented Dec 21, 2015

Glad I read this issue. I have been developing with vagrant on my desktop and laptop separately over the last few weeks, and it became a headache trying to keep files synced.

My case is a bit different in that I have multiple VMs for different purposes, each generated with its own Vagrantfile. Would I have to have a .bashrc file in each directory to isolate each VAGRANT_DOTFILE_PATH file?

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants