/ tips and tricks

HowTo: Running Vagrant with Symbolic Links enabled

Problem: On a Windows host, Vagrant won't have symbolic links in the shared folder

If you are like me, you love Vagrant. One of the problems in recent months was that on my linux-guest system the symbolic links won't work. Long time I thought it's a limitation, but actually is just disabled for security reasons.

If you want to add symbolic links to your vagrant linux guest on a windows host inside the /vagrant directory you need to do two things:

  1. Run vagrant up as administrator
  2. Add code to your vagrant file that Shared-Folders-Enable-Symlinks-Create is enabled

Run vagrant up as administrator

That's the easy part! If you have Mingw installed (comes with the git-bash) you just do something like this:

Add SharedFoldersEnableSymlinksCreate to your vagrant file

You'd have to add this part to your provider configuration:

  config.vm.provider "virtualbox" do |v|
      v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  end

A complete sample file for a Vagrant setup could look like this:

Vagrant.configure("2") do |config|
  config.vm.box = "scotch/box"
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.provider "virtualbox" do |v|
      v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
  end
end

If you have any other tips, let me know in the comments!