Vagrant up error, changing ownership of /vagrant:

2019-02-09 07:45发布

问题:

I'm running Windows 8.1 64-bit on a laptop.

I've been following this guide to try an setup a homestead for my Laravel projects: laravel installation and setup

guide tldr: You just install vagrant, virtual-box and composer. You use these to acquire homestead, then initialize and install. You configure your homestead.yaml and generate ssh keys. After all this you use vagrant up, to have vagrant setup your Vritual machine with your development enviroment and all that stuff.

Using git bash, I follow the guide and get to the 'vagrant up' part.

Here is where it gets hairy, I get the following error:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 80 => 8000 (adapter 1)
    default: 443 => 44300 (adapter 1)
    default: 3306 => 33060 (adapter 1)
    default: 5432 => 54320 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version o
f
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you
 see
    default: shared folder errors, please make sure the guest additions within t
he
    default: virtual machine match the version of VirtualBox you have installed
on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.14
    default: VirtualBox Version: 5.0
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/Work/Homestead/Homestead
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

chown `id -u vagrant`:`id -g vagrant` /vagrant

Stdout from the command:

Stderr from the command:

chown: changing ownership of ���/vagrant���: Not a directory

I have run git bash as admin. my .yaml file looks like this

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: C:/Users/Work/.ssh/id_rsa.pub

keys:
    - C:/Users/Work/.ssh/id_rsa

folders:
    - map: C:/Users/Work/Projects
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

I got the newest version of Vagrant and Virtual Box.

It seems to me like the error comes from the path to the folder being invalid, but seeing as my yaml file should be correct I don't understand how to solve it.

I did successfully install homestead environment on another windows 8.1 stationary PC but I never encountered this error.

回答1:

I've just made it through.

  • So you have Vagrant and the latest VirtualBox.
  • Restart your computer now if you didn't do it after any of the installations
  • Uninstall Vbox 5.0
  • Restart the computer again
  • Download and install 4.3.30 for amd/x86
  • Run vagrant up and there you are


回答2:

Mitchell confirmed for us that this was a bug in the latest version, it's fixed by now: look at this issue and the relevant commit https://github.com/mitchellh/vagrant/issues/5933



回答3:

So, here is how I actually managed to fix it.

The newest versions of Vagrant (1.3.5) and VirtualBox (4.3.4) do not play together at all on Windows. So, I kept Vagrant 1.3.5 and went down to VirtualBox 4.2.2.

Once you have that, you have to get rid of a couple folders so that everything resets itself correctly:

 Users\<<USERNAME>>\.VirtualBox
Users\<<USERNAME>>\.vagrant.d

Delete those before trying to run

vagrant up

With that, I was able to get everything running again. However, I have noticed that running vagrant up does go a tad slower than it had been previously. I can live with that though. Thank you for all of your help and suggestions.



回答4:

Currently Vagrant (<=1.7.3) has a bug with VirtualBox 5.0. According to

https://github.com/mitchellh/vagrant/issues/5933

Vagrant 1.7.4 will have a fix for VB 5.0. It can be applied in-tree though, as I mention on the Github issue.



回答5:

If you get this message then, try to match VirtualBox version on host machine, that will solve the problem.

default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 4.3.10 default: VirtualBox Version: 5.0



回答6:

not 100% sure but what it seems like, vagrant is trying to map it's default "/vagrant" folder to your local C:/Users/Work/Homestead/Homestead. If the local does not exist or has some permission errors, /vagrant will not be created and the next command on it will fail. Have a look if C:/Users/Work/Homestead/Homestead is created. And also I do not see this mapping in your yaml. /vagrant => C:/Users/Work/Homestead/Homestead. Is your config not being overwritten with something?