Symbolic links and synchronized folders in Vagrant

I want to use Vagrant to provide a common development environment for my team. Hosts are completely different:

  • Some use OS X, some Linux, and some Windows.
  • Some use VMware, some use VirtualBox.

Inside the virtual machine, we want to run Linux.

So far so good.

Now our idea was that each developer will be able to use the IDE of their choice, and therefore we presented a synchronized folder that shares the source code between the host and the virtual machine. It basically works as well ... except for symbolic links.

Inside our source code, we actually have some symbolic links, which is not a problem inside Linux inside the VM, but on Windows as a host this causes problems. The only thing we cannot do is get rid of symbolic links, so we need another way to handle this.

So far, we have tried several options:

  • There is a workaround mentioned in issue Vagrant, unfortunately, this is only VirtualBox and does not help those who run VMware. So far, we have not found a way to run code in Vagrantfile depending on the provider used.
  • Instead of using the standard shared folder, we tried using the rsync type. This works on Windows, but a crash on OS X with a number of errors tells us that symlink has no referent (one error for a symbolic link).
  • We thought about NFS , but this only works if you are not using Windows as the host.
  • We are also talking about SMB , but again it only works on Windows as a host.

I can’t imagine that we are the only or first people on this planet to experience problems with multi-platform hosts and symbolic links in a shared folder.

How can you solve this problem so that we can keep symbolic links, but still use different host operating systems?

+91
synchronization vagrant vagrantfile rsync sync
Jun 13 '14 at 7:53 on
source share
6 answers

VirtualBox does not allow symbolic links in public folders for security reasons. To enable symbolic links, you must add the following line to the vm provider configuration block in the Vagrantfile:

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

In addition, on Windows vagrant up must be performed in a shell with administrator rights. No workarounds required.

+56
Jun 23 '14 at 11:58 a.m.
source share

The accepted answer is not good. This question describes a problem with synchronized folders, not public folders. The proposed solution will not affect the rsynced folder (not shared). And even if the OP uses the shared folder, the accepted answer sentence is something that has already been integrated into the tramp with 1.1, released 15 months before the OP posted the question (not to mention the VirtualBox shared folders are awfully slow ).




I ran into the same problem: on OS X, I got a symlink has no referent rsync error. I personally was able to solve it by adding rsync special arguments to my vagrantfile :

 config.vm.synced_folder ".", "/var/www", type: "rsync", rsync__args: ["--verbose", "--archive", "--delete", "-z"] 



I also discovered this problem on roaming github to indicate something that seems to be wrong with the default value for rsync__args (in particular, that one of the default arguments --copy-links seems to break the other, --archive , at least until copying broken symbolic links).

+90
Mar 13 '15 at 0:20
source share

I tried all of these options to resolve the error with running npm install .

Just starting the firewall at the admin command line and loading vm ( vagrant reload ) solved the problem.

I went back and removed the SharedFoldersEnableSymlinksCreate configuration from the Vagrantfile, and everything was fine.

+5
Jan 09 '17 at 0:15
source share

Default synchronized folder type: vboxsf has a known performance problem with a large number of files / directories and does not have support for symbolic links and hard links (see ticket 818 - error 7+ years ago). Avoid using.

A synchronized folder like rsync might be your best bet.

You mentioned that it crashed, which version of rsync are you using? Try upgrading it to version 3.1.0 using brew, I know that OOTB is too old (2.x), which can cause problems.

+2
Jun 17 '14 at 6:26
source share

After fussing for an hour and trying several different solutions ( vagrant-vbguest , Marvin suggested fixing it), I could not get symbolic links in shared folders to work with VirtualBox 4.8.10, Vagrant 1.5.1.

I found that a simpler solution is to set up a separate public folder and then use Ruby File.readlink to read in the base path:

 config.vm.synced_folder File.readlink('SYMLINK'), "/mount/path" 
+1
Nov 25 '14 at 18:15
source share

Add the following line to the Vagrantfile:

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

This worked for me ONLY after I downgraded Virtualbox 6.0.8 to 6.0.4 and vagrant 2.2.4 to 2.2.1.

when you open the terminal (I use git bash on Windows 10) with "Run as administrator".

also try changing git bash: in the project file: $ vim.git / config change to symlinks = true

 [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = true ignorecase = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master 
0
Jun 30 '19 at 11:41
source share



All Articles