How to set permissions to create a vagrantfile - vagrant

Every time I try to run vagrant init I get this error message.
The user that is running Vagrant doesn't have the proper permissions
to write a Vagrantfile to the specified location. Please ensure that
you call vagrant init in a location where the proper permissions
are in place to create a Vagrantfile.
I'm trying to set up Vagrant for the first time. It's just a Windows 10 laptop, and I'm running the command from this directory; C:\Users\admin\Documents\z\bin>
I've looked at that directory and it seems to have full permissions allowed.

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.

How can I set permissions for Magento using a Vagrant shared folder?

I am trying to install a Magento instance using vagrant. I used the MageVagrant repository found here, then modified it so that the default installtion directory on the vagrant machine points to a folder in the /vagrant folder, which is the shared folder (I did this so that I could edit the Magento files on my local machine and store them in version control), so that on my vagrant machine I have a symlink that looks like the following:
/srv/www/magento.localhost.com -> /vagrant/magento.localhost.com
When I try to run the Magento installer, it is fine until I get to the Configuration step of installation, and then I get the following error message:
Path "/srv/www/magento.localhost.com/public_html/app/etc" must be writable.
Path "/srv/www/magento.localhost.com/public_html/var" must be writable.
Path "/srv/www/magento.localhost.com/public_html/media" must be writable.
even though I have run chmod 777 -R on the directories both on my local machine and on the vagrant box. However, it still thinks it is not writable. How can I make these directories writable for the vagrant server?
By default it makes the mounted folder owned by the vagrant user and group, so you could make the web server you are using have permissions for that, or the way I do it is to add another shared folder and explicitly set the permissions on that share to how I want.
Line in my VagrantFile:
config.vm.synced_folder "../project_folder", "/var/www/", owner: "apache", group: "apache"
this will mount the folder "project_folder" which is one level above my vagrant directory to the location "/var/www" inside the virtual machine with the ownership of apache:apache.
This should work.
If you are hosting multiple sites inside the vm I suggest setting this shared folder as the parent of all the sites.

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