{"id":432,"date":"2013-12-20T14:58:21","date_gmt":"2013-12-20T19:58:21","guid":{"rendered":"http:\/\/www.virtualroadside.com\/blog\/?p=432"},"modified":"2014-07-25T11:24:37","modified_gmt":"2014-07-25T16:24:37","slug":"global-shared-development-folder-on-vagrant","status":"publish","type":"post","link":"https:\/\/www.virtualroadside.com\/blog\/index.php\/2013\/12\/20\/global-shared-development-folder-on-vagrant\/","title":{"rendered":"Global shared development folder on Vagrant"},"content":{"rendered":"<p><a href=\"http:\/\/www.vagrantup.com\/\">Vagrant<\/a> is pretty awesome for development. One thing that I&#8217;ve ran into is that I use a lot of vagrant instances at various times, and much of the time I want to access my development files from inside the VM. One thing that is nice about vagrant is that by default it maps the folder where the Vagrantfile is located to \/vagrant inside the VM. However, most of the time the content I want to access isn&#8217;t in that folder, so I found a good way to allow me to access stuff without needing to copy content all over the place.<\/p>\n<p>What you can do is setup a global Vagrantfile, and all of the VMs that are stood up by your username will get the settings inside that VM.\u00c2\u00a0Just create a file \u00c2\u00a0~\/.vagrant.d\/Vagrantfile so it looks like the following. This will map\u00c2\u00a0<span style=\"line-height: 1.5em;\">some local folder to \/src on the vagrant VM &#8212; but of course, you should set the paths to\u00c2\u00a0<\/span>values that make sense for you.<\/p>\n<pre>Vagrant.configure(\"2\") do |config|\r\n\r\n    config.vm.provider :virtualbox do |vbox, override|\r\n\r\n        # path on your local machine\r\n        host_folder_name = \"~\/local\/path\/to\/somewhere\"\r\n\r\n        # path where the local folder is mapped to inside the VM\r\n        vm_folder_name = \"\/src\"\r\n\r\n        # In newer versions of Vagrant, you should use \"type\" otherwise\r\n        # you may find it rsyncing your computer to the VM\r\n        override.vm.synced_folder File.expand_path(host_folder_name), vm_folder_name, type: \"virtualbox\"\r\n    end\r\n\r\nend<\/pre>\n<p>Of course, if you set something like this up, definitely use the <a title=\"Beware of using Vagrant VMs on a bridged network\" href=\"http:\/\/www.virtualroadside.com\/blog\/index.php\/2013\/12\/10\/beware-of-using-vagrant-vms-on-a-bridged-network\/\">vagrant-rekey-ssh<\/a> plugin to make sure that nobody else is able to access your VM via SSH using the default insecure vagrant keys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vagrant is pretty awesome for development. One thing that I&#8217;ve ran into is that I use a lot of vagrant instances at various times, and much of the time I want to access my development files from inside the VM. One thing that is nice about vagrant is that by default it maps the folder [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"_links":{"self":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/432"}],"collection":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":3,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":459,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions\/459"}],"wp:attachment":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}