如何修复 Homestead Vagrant 错误 "Configuring and enabling network interfaces... `await_response_state': Agent pid 3330 (RuntimeError)"

How can I fix Homestead Vagrant error "Configuring and enabling network interfaces... `await_response_state': Agent pid 3330 (RuntimeError)"

我正在使用 Laravel 7.x Homestead。多年来一切都很好,也许直到我从 6.x 升级到 7.x 左右(虽然我不确定,因为我不经常尝试重新加载)。

现在每当我 运行 cd /c/code/Homestead/ && vagrant upcd /c/code/Homestead/ && vagrant reload --provision 发生这种情况时:

==> vboxHomestead: Machine booted and ready!
==> vboxHomestead: Checking for guest additions in VM...
    vboxHomestead: The guest additions on this VM do not match the installed version of
    vboxHomestead: VirtualBox! In most cases this is fine, but in rare cases it can
    vboxHomestead: prevent things such as shared folders from working properly. If you see
    vboxHomestead: shared folder errors, please make sure the guest additions within the
    vboxHomestead: virtual machine match the version of VirtualBox you have installed on
    vboxHomestead: your host and reload your VM.
    vboxHomestead:
    vboxHomestead: Guest Additions Version: 6.0.0 r127566
    vboxHomestead: VirtualBox Version: 6.1
==> vboxHomestead: Setting hostname...
==> vboxHomestead: Configuring and enabling network interfaces...
C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-scp-1.2.1/lib/net/scp.rb:398:in `await_response_state': Agent pid 3330 (RuntimeError)
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 levels) in start_command'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/channel.rb:323:in `process'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:250:in `block in ev_preprocess'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:540:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:540:in `each_channel'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:250:in `ev_preprocess'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/event_loop.rb:101:in `each'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/event_loop.rb:101:in `ev_preprocess'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/event_loop.rb:29:in `process'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:228:in `process'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:181:in `block in loop'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:181:in `loop'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/session.rb:181:in `loop'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-ssh-5.1.0/lib/net/ssh/connection/channel.rb:272:in `wait'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-scp-1.2.1/lib/net/scp.rb:284:in `upload!'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:327:in `block (2 levels) in upload'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:333:in `block in upload'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:742:in `block in scp_connect'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:382:in `connect'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:740:in `scp_connect'
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/communicators/ssh/communicator.rb:303:in `upload'
...

此外,试图破坏盒子会导致类似的错误:

vagrant destroy
==> vboxHomestead: Running action triggers before destroy ...
==> vboxHomestead: Running trigger...
==> vboxHomestead: Backing up mysql database homestead...
==> vboxHomestead: Trigger run failed
C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-scp-1.2.1/lib/net/scp.rb:398:in `await_response_state': Agent pid 4861 (RuntimeError)
        from C:/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 le...

除非我在 Homestead.yaml 中注释掉 backup: true。然后vagrant destroy就可以了,然后vagrant up就可以了,我用了一段时间的机器,最后又运行又陷入了这个问题。

如何缩小问题所在的范围?

我正在使用 Vagrant 2.2.7、VirtualBox 6.1.4、Homestead v10.5.1,它使用 box 'laravel/homestead' 版本 '9.3.0'。

Homestead 维护者says:

We can't guarantee results of vagrant reload --provision and I generally advise against using it unless you're really comfortable with what Vagrant is doing and what your provisioners are doing.

我遇到了类似的问题,发现它是由登录配置文件(/etc/profile 或 /etc/prfile.d/*)向终端回显某些内容引起的。我认为当您以 root 身份登录时,您会发现文本“Agent pid 3330”来自其中一个配置文件。评论出来,问题应该消失或排除以 root 身份登录时的回显消息。