Vagrant command doesn't work without Sudo - terminal

I have installed homestead with Vagrant in my MacOS. I have installed all with Virtual Box, but when i try to use vagrant command in my terminal for running Virtual Machine appear this error:
The VirtualBox VM was created with a user that doesn't match the
current user running Vagrant. VirtualBox requires that the same user
be used to manage the VM that was created. Please re-run Vagrant with
that user. This is not a Vagrant issue.
I try with sudo vagrant up and it work but is not the best choice.
Anyone can help me?
There's a screenshot of the terminal Error:
Terminal Error with command vagrant up and vagrant ssh.

Try deleting .vagrant directory
rm -r .vagrant
I suspect you copied or moved project folder from one place to another.
Alternatively you need to update the creator_uid file in .vagrant/. Check out this blog post.

Related

Vagrant was unable to mount VirtualBox shared folders. ERROR: INVALID ARGUMENT

I know that other people during the years had met similar problems (like this ) however in my case the guest addition is installed (0.30.0 version) and I tried to reinstall it a lot of times.
I work on Windows10 and those are the version of VirtualBox and Virtual Machine.
Virtualbox on your host claims: 5.2.8
VBoxService inside the vm claims: 6.1.22
This is the code of the problem:
default: /vagrant => C:/Users/XXXX XXXX/Documents/src
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
I never found the error Invalid argument in similar cases so my question is if this need a particular procedure.
Thank you very much
Just had a similar problem after an update - was getting the same:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
What I found in virtualbox startup was the message:
VirtualBox Guest Additions: Kernel headers not found for target kernel
5.4.0-81-generic. Please install them and execute
/sbin/rcvboxadd setup
Used "vagrant ssh" to access the virtualbox command line and ran:
sudo apt-get install linux-headers-$(uname -r)
After that restarted vagrant:
vagrant halt
vagrant up
Then it actually built the VirtualBox Guest Additions properly and mounted my shared folders.
Had the same exact error as you after making my second vagrant project - specifically after changing my public_network setting.
mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument
At I also tried several solutions from people's answers like the one mentioned here and updated my VirtualBox.
I'm not really sure how mine works but here's what I did:
I logged into the VM (vagrant ssh) and installed the guest additions manually
cd /opt
sudo wget -c
http://download.virtualbox.org/virtualbox/6.1.26/VBoxGuestAdditions_6.1.26.iso O VBoxGuestAdditions_6.1.26.iso
And then tried:
sudo mount VBoxGuestAdditions_5.1.28.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run
But I got an error saying something like permission denied or no directory.
So I reload vagrant (vagrant reload), but the error still occurred. However, I still continued trying something else, so I thought maybe I should install the vbguest plugin and did this:
vagrant plugin install vagrant-vbguest
That removed the error for me after reload but when I logged into vagrant again, I still can't see my shared folders so I halted my vb and run provision:
vagrant up --provision
Then I got a message which said that there was an error while executing VBoxManage so on and so forth. So I paused all running machine in my VB, closed all running VB apps in my desktop, and run the command:
vagrant destroy
After recreating vagrant vagrant up, everything miraculously worked! I can now navigate to my shared folders' directory.
I'm still in the process of learning vagrant so I can't really explain what actually happened in my machine but I hope this can somehow be of help to you or to someone who have the same issue.
Step 1: open virtual box then right click on installation machine then ->close->power off.
Step 2: then run below command
vagrant halt
vagrant up
Finally got it working the following way (this related answer was of great help along with Paul_Z's answer in this same question).
Step 1:
Make sure VirtualBox Guest Additions Software is installed.
If this solved your Issue, then great! If not, continue on to step 2.
Step 2:
Read the VirtualBox Guest Additions installation output carefully.
(If no longer possible, you can rerun the setup by using cd to go to
/opt/VBoxGuestAdditions-*your-version-number-here*/init/
and then run:
sudo ./vboxadd setup)
Step 3:
Install the needed dependencies with the distribution's package manager that the error message shows. (In my particular case, it mentioned that the system couldn't perform kernel module builds because gcc make and perl were not present in the system).
Step 4:
Rerun the VirtualBox Guest Additions setup by going to
/opt/VBoxGuestAdditions-*your-version-number-here*/init/
and then run:
sudo ./vboxadd setup
(If more dependencies are requested, go back to step 3)
Step 5: Reboot
Step 6 (Optional):
Add user to vboxsf group so that it is able to access the shared folder if needed. (As explained in this answer).
sudo usermod -G vboxsf -a your_user_name
I have the issue i Ubuntu 20.04 and simply download a more recent version of VirtualBox, then extract the GuestAditions ISO and installed it
I ran just
vagrant plugin install vagrant-vbguest
and after this the box came up.

Vagrant box not found

According to Magento PHP Developer's Guide, I have been setting up Vagrant with Virtualbox on a Fedora Workstation 22 setup. This install went mostly as planned with the exception that I had to install a few kernel header files and libvirt related packages in order to get Virtualbox up and running.
Then I ran:
>vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
>vagrant init lucid32 #A Vagrantfile is successfully created in my home directory
>vagrant up
Both as root and not as root. vagrant up has permission issues when I do it without root. As root, it is having trouble finding my box because it is looking in my home directory where the file does not exist. My questions are:
1) Why is it looking in the wrong place (home)? Or,
2) Why has the box not been created in home? Or,
3) How can I specify the box location in a vagrant command or environment variable?
This issue was fixed by upgrading Vagrant from 1.7.2 to 1.7.3.

No synced vagrant folder to be found

I am trying to work through the "Getting Started" section at the vagrant site. I run through the two commands they show:
$ vagrant init hashicorp/precise32
$ vagrant up
All seems to go well. I then run these two commands:
$ vagrant ssh
$ lsb_release -a
The result shows I'm running on Ubuntu 12.04, precise. So far so good.
However, when I do an 'ls' the only thing in the directory is a postinstall.sh file. I thought I should have been in the same directory as the Vagrantfile.
Sorry for such a newbie question. I'm sure its something basic I messed up.
I'm doing this on an Ubuntu 14.10 box with Virtualbox 4.3.22 and Vagrant 1.7.2 installed.
Thanks
By default, Vagrant will share your project directory (the directory with the Vagrantfile) to /vagrant on the guest machine.

How do I remove a Vagrant box from global-status, after deleting that box from the filesystem?

I deleted a folder containing a running Vagrant box before realising it was still running.
How can I delete it from Vagrant (global-status) now?
I already removed the Virtualbox VM.
To discard old boxes listed in vagrant global-status (eg. you deleted the folder containing the .vagrant dir from the filesystem) you just need to run:
vagrant global-status --prune
You might need to remove the Virtual Machine directly from your provider (VMWare, Virtualbox, ..) control interface.
I believe that the new filename of the global data is ~/.vagrant.d.
So you can run rm -r ~/.vagrant.d to delete all user data for a fresh start.
For my case: Where kitchen and .kitchen/ folder may contain hidden vagrant files create by
$ kitchen create
I need to go further than either kitchen destroy or vagrant destroy or even vagrant destroy machineID ( from vagrant global-status - which gives a list of vagrant instances across your user space. )
In my case, I had to blow away the vagrant machine lock files contained in the users .vagrant hidden directory.
$ rm -r ~/.vagrant/data
And in my case I need to sudo the above command.
Then I finally got to a clean
$ vagrant global-status
list
First you use vagrant global-status to list all the vagrant machines and their status and ids.
then you can use:
vagrant destroy -f the_id_of_the_machine
after that if you run vagrant global-status again you will find that the id you have specified in the vagrant destroy -f command has been removed from the list.
and then you might need to restart your machine However these commands will not affect your boxes.
The above commands didn't remove the old box in my case on a Windows machine. I had already removed the .vagrant folder and the box from the virtualbox provider folder but the box was still in the vagrant global-status list.
As mentioned in the comment given by a vagrant up command:
If you believe this message is in error, please check the process
listing for any "ruby" or "vagrant" processes and kill them. Then
try again.
So I killed ruby.exe from the process list and did a subsequent vagrant global-status --prune.

Ubuntu guest can't see Vagrantfile in Window's host project directory

I just installed Vagrant 1.4.3 on Windows 7 64-bit and created an Ubuntu 13.10 (Saucy) box using the following:
vagrant box add saucy64-20140226 http://cloud-images.ubuntu.com/vagrant/saucy/20140226/saucy-server-cloudimg-amd64-vagrant-disk1.box
vagrant init saucy64-20140226
After doing:
vagrant up
I SSH'ed to the vagrant box using Putty. Up to this point is fine, but when I do:
$ ls
in the /vagrant directory (on the Guest), I do not see my 'Vagrantfile' or any other files from the Host machine.
Also, any files created in the Guest's /vagrant directory do not show up in the Host's synced directory.
I noticed the following when the box/vm was starting up:
[default] The guest additions on this VM do not match the installed
version of VirtualBox! In most cases this is fine, but in rare cases
it can prevent things such as shared folders from working properly. If
you see shared folder errors, please make sure the guest additions
within the virtual machine match the version of VirtualBox you have
installed on your host and reload your VM.
After researching a little more, found that the following solves the issue:
https://github.com/dotless-de/vagrant-vbguest
Here's a more detailed post:
http://kvz.io/blog/2013/01/16/vagrant-tip-keep-virtualbox-guest-additions-in-sync/
Thanks very much to the folks who created the 'vagrant-vbguest' Vagrant plugin!!!

Resources