Pierre-O's Blog

My personnal blog about IT stuff

How to Isolate Vagrant Env

As you may have noticed, vagrant changed version. Of course, I downloaded the last version. The issue is that, there is a .vagrant.d in your home that help to configure it, and different version of vagrant use different configurations.

I wanted a totally isolated environment. I’m now using a Runmefile in my environment to change the pointer to the .vagrant.d folder.

Here is how I did it :

Add a hook in your .zshrcmy .zshrc
1
2
3
4
5
6
7
8
9
10
11
12
13
_within-runme-project() {
  local check_dir=$PWD
  if [ $check_dir != "/" ]; then
    [ -f "$check_dir/Runmefile" ] && return
  fi
  false
}

function chpwd() {
  if _within-runme-project; then
    source ./Runmefile
  fi
}

And Add a Runmefile in your project :

Now each time you cdto your working directory, it’ll change your pointer to .vagrant.d folder \o/

As always, feel free to comment/insult/troll!