6

When I create a virtual machine through vagrant, and ssh into the machine the "/vagrant" folder does not exist.

Currently Running the following

Note there is no mention of "Mounting Shared Folders" when the machine boots up. The Vagrantfile is the standard file created from "vagrant init".

Any help on to why this may be happening would be much appreciated. Thanks.

wc250
  • 129
  • 3
  • 10

1 Answers1

6

make sure that in your Vagrantfile you dont have something

config.vm.synced_folder ".", "/vagrant", disabled: true

Also if you dont, force the default /vagrant folder to be shared

config.vm.synced_folder ".", "/vagrant"

when booting your VM, you should have logs like

==> default: Mounting shared folders...
    default: /vagrant => /Users/.....path to project directory

If nothing works, 2 things you can explore:

  • is sync_folder working with another folder definition ?
  • boot with debug option vagrant up --debug to see whats happening after Mounting shared folders
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • 3
    Synced folders **were not** initially disabled. Adding the `config.vm.synced_folder ".","/vagrant"` worked. However, that seems like a bit of a workaround. Is that not supposed to be default behavior? – wc250 May 30 '16 at 21:14
  • 1
    it could be because of a 1) global vagrantfile or the 2) box vagrantfile - to check create a VM from another box (like `ubuntu/wily64` for example) and see if `/vagrant` is set; if it works it means your current box has Vagrantfile which deactivate the sync folder. If the folder is still disabled it could be because it is disabled in a global vagrantfile – Frederic Henri May 31 '16 at 07:37
  • 3
    ok then it might be an issue with the previous box, check if you have a file ~/.vagrant.d/boxes//0/virtualbox/Vagrantfile ? if you do check content of the file to see if you have a disable sync folder – Frederic Henri May 31 '16 at 11:27
  • 1
    None of these worked for me. Vagrant refuses to mount the host directory to `/vagrant`. – Steve Jul 14 '20 at 01:20
  • @Distortum which box do you have ? – Frederic Henri Jul 14 '20 at 15:43
  • @FredericHenri never mind. It was caused by the box not having my ssh public key. Without ssh authentication, there’s no file sync. – Steve Jul 14 '20 at 15:55