A VirtualBox machine with the name 'homestead' already exists

前端 未结 30 3721
旧巷少年郎
旧巷少年郎 2020-12-02 04:58

Since homestead 2.0 homestead laravel has not been working

I don\'t know why \'homestead init\' creates a Homestead.yaml file in mydirectory/.homestead and not in

相关标签:
30条回答
  • 2020-12-02 05:33

    You can open the VirtualBox GUI and remove the conflicting virtual machine.

    0 讨论(0)
  • 2020-12-02 05:34

    The Vagrant relies on VirtualBox (if that's the default provider) so it checks for existing environment first before provisioning your VM.

    It is executing the following command:

    VBoxManage list vms
    

    and when it finds the VM with the same hostname, so it'll fail.

    You can debug it by:

    vagrant --debug up
    

    to find out the exact reason.


    Solution

    If you're planning to use multiple VMs in different folders, then you need to change your config.vm.hostname (possibly config.vm.provider(name) as well) in your Vagrantfile to make it unique. Or simply remove it, so Vagrant will assign a different name for each VM.

    If that's not the case, simply shutdown and unregister previous VM which conflicts by running:

    VBoxManage controlvm NAMEOFVM poweroff
    VBoxManage unregistervm NAMEOFVM --delete
    

    and re-run your vagrant up.

    If it fails on directory rename (because you missed --delete), then rename or remove the destination folder, for example:

    rm -fr ~/"VirtualBox VMs/NAMEOFVM"
    

    and re-try again.


    This problem may be related to: GitHub issue #2969 - vagrant up not detecting a previously run VM

    0 讨论(0)
  • 2020-12-02 05:35

    From the following message :

    A VirtualBox machine with the name 'vm_name' already exists. Please use another name or delete the machine with the existing name, and try again.

    I listed current running virtual machines from the command line :

    VBoxManage list vms
    

    Result :

    "vm_name" {8ba467b7-da96-4f68-9bf8-671dd6f0d007}

    Then proceeded with the removal of the offending virtual machine :

    VBoxManage unregistervm 8ba467b7-da96-4f68-9bf8-671dd6f0d007 --delete
    
    0 讨论(0)
  • 2020-12-02 05:35

    I had the following error:

    Error:

    A VirtualBox machine with the name 'homestead-7' already exists.
    Please use another name or delete the machine with the existing
    name, and try again.
    

    Solution:

    • Find the VirtualBox VMS folder, in my case it was in ~/VirtualBox VMs
    • List the elements in the folder with ls command, and review if the virtual machine is there
    • Delete the folder with the name of the machine, in my case homestead-7
    • Re-execute the vagrant up command in the homestead folder

    That's all, I hope it's helpful, that was my solution.

    Regards!

    0 讨论(0)
  • 2020-12-02 05:38

    If you want to keep keep your machine, without destroying and recreating following steps should solve your problem. (I work on OS X El Captain, Vagrant 1.8.1)

    Run homestead in debug mode

    homestead --debug up
    

    Look for something like in the output:

    INFO machine: Initializing machine: default INFO machine: - Provider: VagrantPlugins::ProviderVirtualBox::Provider INFO machine: - Box: # INFO machine: - Data dir: /Users/YOUR_HOME_DIR/Workspace/Homestead/.vagrant/machines/default/virtualbox

    Data dir, is the path which is interesting for you.

    Then vboxmanage list vms

    "homestead" {0e8438b9-4a67-4fb1-80cb-2c62cf04ab5c} "settler_default_1447385930122_73498_1474294682778_13108" {93ecb93f-f159-4406-a384-5312b4d3ab34}

    Edit id file, in the path which you found out in the previous command

    vi /Users/YOUR_HOME_DIR/Workspace/Homestead/.vagrant/machines/default/virtualbox/id
    

    Replace content of that file, with the id of the VM you want to fix, in this scenario it is

    0e8438b9-4a67-4fb1-80cb-2c62cf04ab5c

    Now try

    homestead up
    

    VM should start booting. It might work, or you might have issues with ssh authentication

    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Authentication failure. Retrying...     default: Warning: Authentication failure. Retrying...
    

    To fix that do following Check Homestead SSH config

    homestead ssh-config
    

    You should get something like

    Host default HostName 127.0.0.1 User vagrant Port 2222
    UserKnownHostsFile /dev/null StrictHostKeyChecking no
    PasswordAuthentication no
    IdentityFile "/Users/pryznar/.vagrant.d/insecure_private_key"
    IdentitiesOnly yes LogLevel FATAL

    Edit IdentityFile file

    /Users/YOUR_HOME_DIR/.vagrant.d/insecure_private_key
    

    Check Homestead.yml

    cat /Users/YOUR_HOME_DIR/.homestead/Homestead.yaml
    

    Then copy path to the file under the key keys, and copy private key from that file

    cat ~/.homestead/ssh/id_rsa
    

    Last step is to replace private key in /Users/YOUR_HOME_DIR/.vagrant.d/insecure_private_key with the one you just copied

    Now try rung homestead again, should work.

    homestead up
    

    I got some warnings, but so far it works without issues

    ==> default: Warning: Using a password on the command line interface can be insecure. ==> default: ERROR 1045 (28000): Access denied for user 'homestead'@'localhost' (using password: YES) The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

    0 讨论(0)
  • 2020-12-02 05:38

    Renaming an already existing default VM

    Disclaimer

    The following procedure will destroy your VM and may be only suiteable in a desting-environment like mine! For production environments, consider to repair the association like described here

    I had this problem after overriding the default name of an already existing VM by using

    Vagrant.configure("2") do |config|
      config.vm.define :ubuntu_test
    

    where the VirtualBox name was also set (as a newbie I assumed that Vagrand will use this name too)

    config.vm.provider "virtualbox" do |vb|
         vb.name = "Ubuntu-Test"
    end
    

    By adding config.vm.define it seems that Vagrant doesn't associate the VirtualBox VM any more with the Vagrant file since even vagrant destroy -f say VM not created but vagrant up throw this error

    A VirtualBox machine with the name 'Ubuntu-Test' already exists.

    To delete those zombie VM
    1. If the VM is running, stop it first: vboxmanage shutdown <VMName> (Here the name is Ubuntu-Test)
    2. Get the Id by running vboxmanage list vms
    3. Delete it: vboxmanage unregistervm <Id> --delete
    4. Now your VM can be re-created using vagrant up
    5. Using vagrant global-status --prune, your new name is present
    0 讨论(0)
提交回复
热议问题