Error when running vagrant: "The host path of the shared folder is missing" - vagrant

I have downloaded a Vagrantfile, but when i run vagrant up in terminal the following message appears:
Bringing machine 'default' up with 'virtualbox' provider... There are
errors in the configuration of this machine. Please fix the following
errors and try again:
vm:
* The host path of the shared folder is missing: ~/Sync
OBS.: Using Ubuntu 14.10
I created a folder named Sync in my home.

According to Vagrant docs host path must be either absolute (i.e. /home/user/Sync) or relative to project root (place where your Vagrantfile is).
Relative to project root means if your Vagrantfile resides in /home/user/MyProject then setting up path as "Sync" will create share from /home/user/MyProject/Sync.
Ref: http://docs.vagrantup.com/v2/synced-folders/basic_usage.html

I assumed you are in linux or mac. Type in "pwd" and enter in the terminal where Homestead.yml is.
Mine is "/home/idhamhafidz/Code/opp190-ama"
Then go to your Homestead.yml and edit the folders section like in the image below:
Then quit edit Homesteady.yml and re-run vagrant up again.

In my case it was a space at the end of the path in config.yaml:
source: '/Users/h/Packt/Code '
I've deleted this space and it's working now.

If you are using Vagrant and Windows Subsystem for Linux then you can solve the issue creating a symlink
ln -s /mnt/c/Users/user/project ~/project
/mnt/c/Users/user/project should match the Vagrant project in your Windows machine.
~/project should match the path that is missing.
Note, that you may need to create any intermediary directories.

I know this is an old question, but for anyone just encountering this issue and having a hard time finding a conclusion the answer by #megawebmaster would be the correct approach in giving the relative path to the folder: "/home/(your-pc-username)/Sync/".
Also with a Vagrantfile being ruby-based I personally use ruby's ENV object:
#{ENV["HOME"]}/Sync should resolve the issue.

I came across the same problem and
mkdir ~/Sync help me solve it.

Related

setting up a synced folder that may not exist

In my vagrantfile, I've set up a synced folder, such as
node_config.vm.synced_folder "../.", "/proj_root"
This works fine. I'd like to add other synced foldrs where the source directory may not exist on the host machine. When vagrant runs, it reports that it can't find the source directory
There are errors in the configuration of this machine. Please fix
the following errors and try again:
vm:
* The host path of the shared folder is missing: ../../test_no_such_dir
I understand the error, however, I'm looking for a way to optionally set up the synced_folder. Perhaps I can just run mkdir on the directories to create them if they don't exist, but I'm not sure if I can run arbitrary commands in the vagrantfile.
There are optional args that I can use. One of them is create which creates the source directory if it doesn't exist.
node_config.vm.synced_folder "../../test_no_such", "/test_no_such", create:true

Vagrant SSH Permissions

I am new to Vagrant and get the following error on vagrant up or vagrant ssh:
The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
permissions on the following file to 0600 and then try running this command again:
[...]/.vagrant/machines/default/virtualbox/private_key
I have run:
$ sudo chmod 666 [...]/.vagrant/machines/default/virtualbox/private_key
I also tried (600, 777) but still get the same error.
Please can someone tell me what is wrong and how to fix it?
I just had this issue, and I worked around it moving the private_key file to another place, changing its permission, and then creating a symbolic link at the original place.
So,
$ mv [...]/.vagrant/machines/default/virtualbox/private_key /some/path/where/you/can/change/permissions
$ ln -s /some/path/where/you/can/change/permissions [...]/.vagrant/machines/default/virtualbox/private_key
If you're using the Windows Subsystem for Linux (WSL), this error can occur when you're trying to vagrant up in a directory that is outside the user's home directory.
From the Vagrant docs:
If a Vagrant project directory is not within the user's home directory on the Windows system, certain actions that include permission checks may fail (like vagrant ssh). When accessing Vagrant projects outside the WSL Vagrant will skip these permission checks when the project path is within the path defined in the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH environment variable.
Changing the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH to the current working directory (or a directory above it) can fix this. For example, if your project is in /mnt/c/www, then set the environment variable accordingly:
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/www"
I got the same error now. The problem happened because i was trying to do vagrant up in an NTFS partition, just like the error message tell me.
So i created an directory link in my ext4 partition and an simbloc link in my NTFS to solve this. Works Fine now!
Thanks!
I had this same problem and turns out chmod seems to be working fine but is not actually changing permissions, my files where at an NTFS partition, try changing them to an ext4 or similar.
Got this error using otto (which layers on vagrant)
It is def filesystem related, have a fat partition to allow use with windows (used to, no longer). When the permissions couldn't be set on the partition I just copied the whole directory over to my user directory (as I always should have).
Was using git so I just reset to head to get back to my starting place... re-ran:
otto compile
otto dev
up and running now.

Cannot access Vagrant shared folders

I just trying to add Vagrant to my workflow and I have following probably noob problem. I pull standard hashicorp standard 14.04 image, vagrant up it, SSH to it install my python requirements on it and then then try to execute build commands against code in Vagrant shared folder and run in to problems. Basic errors I get say those locations don't exist or cannot be found.
First action I, go ls /vagrant and can see my shared folders. I cannot cd to them from Vagrant machine I have tried to halt the machine.
Vagrantfile shared folder code.
{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/Kimmo/Documents/Mist.io","disabled":false}}}
I am using Virtualbox as provider newest version.
My dev machine is OSX 10.9.5
There are not access limitations on the folder itself.
Thanks for you help in advance :)
Does /vagrant exists inside the VM just after you start it ?
If no you can add this parameter : "create":true. According to the doc, for the create: true paramater : If true, the host path will be created if it does not exist. Defaults to false.
If the folder /vagrant exists but you can cd or ls it, you can add parameters wich will define the right/owner of this folder:
owner: (string) the user who should be the owner of this synced folder. By default this will be the SSH user. Some synced folder types don't support modifying the owner.
group: (string) the group that will own the synced folder. By default this will be the SSH user. Some synced folder types don't support modifying the group.
Also for the hostpath parameter you have to give him a folder path, not a file path. In your conf I can see: "hostpath":"/Users/Kimmo/Documents/Mist.io". If Mist.io is a file and you want to access this file inside your VM, just give the path to the folder containing this file, /Users/Kimmo/Documents in your case.

Vagrant syncing process

I've just started using Vagrant and I've managed to set up a box ok it seems. I have been a little confused about syncing folders work though. I took from Vagrant that syncing allowed you to use the file system on your Mac and then sync those changes into your virtual machine, is that right?
I have these settings currently
config.vm.synced_folder "../../../Library/WebServer/Documents/", "/Users/jonnny/ubuntu-vagrant/www"
I would expect that now that when I look in chrome that inside my 127.0.0.1:1234/www/
That the files within my Library/WebServer/Documents/ would be there. But they're not, have I done it wrong or misunderstood what's going on here?
Update
I wasn't sure what you meant with my file/folder structure, so probably best I just show them.
Users
Jonnny
ubuntu-vagrant
- Vagrantfile
- /www (dir)
- bootstrap.sh
VagrantFile
VirtualBox VMs
- ubuntu-vagrant_342374982374923
- box-disk1.vmdk
- logs (dir)
- ubuntu-vagrant_342374982374923.vbox
I did try your suggestion and reload the box, but the folder still didn't seem synced.
The syntax seems to be correct. But for the second argument, /Users/jonnny/ubuntu-vagrant/www, it should be the targeted location inside the ubuntu filesystem, not the one which will be created on your Mac OS filesystem.
Try something like /www/ or /usr/johnny/www, according to the location you want.
Update
For the vagrant arguments:
the first should be the location of the folder you want to share inside your Mac Os filesystem relatively from where the Vagrantfile is in your Mac Os filesystem.
the second is where inside the ubuntu-vagrant filesystem you want to access these files.
I think your folder structure is not good: you dont need a Vagrantfile folder or a www folder in your Mac OS filesystem. Just consider one folder: the one where the Vagrantfile is, Users/Johhny/ubuntu-vagrant. The www folder will just exists inside the VM. Then if the Library folder is at the same level than the Users folder in your Mac OS filesystem, you should have :
Library
...
Users
Johhny
ubuntu-vagrant
Vagrantfile
bootstrap.sh
And inside the Vagrantfile you should have this line :
config.vm.synced_folder "../../../Library/WebServer/Documents/", "/www", create: true
According to the doc, for the create: true paramater : If true, the host path will be created if it does not exist. Defaults to false.

downloaded vagrant box file but what to do with it

I had a dev setup the vagrant box and he uploaded the file which I now have on my local machine. But I am not sure how to use it as I never used vagrant before. Can someone help with the docs or directions.
thanks
Full documentation for Vagrant can be found on the website. From a practical point of view, a Vagrant box is just a provisioned VirtualBox VM.
If someone else gave you the box, they can show you how to log into it as well. After that, get coding!
Having the box file is one of the steps to have a proper development environment configured. You also need to have the configuration file vagrantfile.
Vagrant is meant to run with one Vagrantfile per project. For example; if your project path is located at C:\vagrant\project01\, inside that folder you need to put the vagrantfile related to that box. Remember this file should contain the configuration for the box that you previously downloaded.
In the case that you don’t have this file but want to use the box to adapt it to you needs you can also can configure Vagrant for that. You just need to go to the cmd, and cd (got to directory) folder of the project, in this case C:\vagrant\project01\. In the cmd windows type vagrant init and Vagrant will generate a vagrantfile for this project. In that file you can modify the config.vm.box_url parameter to point to your current box. This address could be a URI or the path to the box in your host machine for example “c:\virtualmachines\devel\machineboxname.box”.
Vagrant is so powerful that we have done no more than skim the surface of these topics.
If you just want to re-package a .box file that you were given, then you can try "vagrant box add " where the address is a URL or a physical address. Once that box is added, you can call "vagrant init" to generate your Vagrantfile and "vagrant up" to make a virtual machine based on your friend's base box. The folder that you're currently in then becomes the place where you do all future vagrant commands for this virtual machine.

Resources