Why do different copies of Vagrantfile pointing to same Vagrantbox give different results?

There are 2 Vagrant boxes, 18.04 and 20.04.

There are two Vagrantfiles, vA := `./Vagrantfile` and vB := `./project2/Vagrantfile`.

My goal is to use the env provided by `vA` to successfully run `project2`, as I already can do with `vB`. Why not just use `vB`, then? The reason for this is there is a `./project1` which I would like to be able to freely interact with from within a single Vagrant VM, but is not visible to `vB`.

I have tried nearly decade-old advice of altering the `id` file in `.vagrant/`. The result has been that the same instance is re-used between `vA` and `vB` (because `vagrant global-status --prune` now gives 1 line, whereas before it gave me 2), but it seems that this doesn't necessarily mean that the same set of modules/packages are available. I have `diff`ed the two Vagrantfiles to ensure the modules listed are the same, as well as using `vagrant destroy` to have the system reconfigure itself.

My expectation is, if (1) I specify the same set of packages in any number of `Vagrantfile`s, and (2) have the `id` file in each `.vagrant` directory pointing to the box that works, then (3) I should be able to port the same functionality in whichever of these `Vagrantfile`s that I decide to `vagrant up`. But Vagrant doesn't seem to agree 🙂

What am I missing here?

1 thought on “Why do different copies of Vagrantfile pointing to same Vagrantbox give different results?”

  1. I’m confused about what you’re trying to accomplish. Why not just have two separate VMs for project1 and project2?

    Reply

Leave a Comment