Execute Vagrant on Windows 10 and get an error: Vagrant failed to initialize at a very early stage
1. Execute Vagrant on Windows 10 and report an error: Vagrant failed to initialize at a very early stage, as shown in Figure 1
PS E:\wwwroot\channel-pub-api> vagrant Vagrant failed to initialize at a very early stage: The plugins failed to initialize correctly. Modifications made within the vagrant home directory. Vagrant can Attempt to automatically correct this issue by running: Vagrant Plugin Repair If vagrant was later updated, this error may be due to incompatible Versions of dependencies. To fix this problem please remove and re-install All plugins. Vagrant can attach to do this automatically by running: vagrant plugin expunge --reinstall Or you may want to try updating the installed plugins to their latest versions: Vagrant plugin update Error message giving initialization: Unable to resolve Dependency: user requestedvagrant-vbguest (= 0.15.1)
2. The reason should be that Vagrant has been updated recently, and Vagrant can be automatically tried by running the following command (remove and reinstall
All plugins), follow the prompts to execute the command
PS E:\wwwroot\channel-pub-api> vagrant plugin expunge --reinstall This command permanently deletes all currently installed user plugins. It should only be used when a repair command is unable to properly fix the system. continue?[N]: yes All user installed plugins have been removed from this vagrant environment! Vagrant will now attempt to reinstall user plugins that were removed.
3. Execute the following command, after over the wall, the execution of the command in Windows PowerShell still reports the same error
PS E:\wwwroot\channel-pub-api> vagrant plugin install vagrant-hostmanager installing thevagrant-hostmanagerPlugin. This can take a few minutes... Vagrant failed to load a configured plugin source. By a variety of issues including: Transient Connectivity Issues, Proxy Filtering rejecting access to a configured plugin source, or a configured Plugin source not responding correctly. Please review the error message Below to help resolve the issue: SSL_Connect Syscall returned=5 errno=0 state=ssslv2/v3 read server hello a (https://gems.hashicorp.com/specs.4.8.gz) Source: https://gems.hashicorp.com/
4. Execute the following command in the Windows command prompt, and the execution is successful
E:\wwwroot\channel-pub-api>vagrant plugin install vagrant-hostmanager installing thevagrant-hostmanagerPlugin. This can take a few minutes... fetching: vagrant-hostmanager-1.8.9.gem (100%) installed the pluginVagrant-HostManager (1.8.9)!
5. Execute Vagrant again and report an error:
E:\wwwroot\channel-pub-api>vagrant Vagrant failed to initialize at a very early stage: There is a syntax error in the following vagrantfile. Message is reproduced below for convenience: E:/WWWRoot/Channel-PUB-API/VagrantFile:15: Syntax Error, Unexpected Tidentifier, Expecting} weibo:channel-pub-api-weibo.te ^
6. Edit VagrantFile, in the domains configuration, there is a missing English comma in the 14 lines in the domains configuration, as shown in Figure 2
domains = {
frontend:channel-pub-api-frontend.test,
backend:channel-pub-api-backend.test,
API:channel-pub-api-api.test,
qq:channel-pub-api-qq.test,
RPC:channel-pub-api-rpc.test
weibo:channel-pub-api-weibo.test,
wx:channel-pub-api-wx.test
}
domains = {
frontend:channel-pub-api-frontend.test,
backend:channel-pub-api-backend.test,
API:channel-pub-api-api.test,
qq:channel-pub-api-qq.test,
RPC:channel-pub-api-rpc.test,
weibo:channel-pub-api-weibo.test,
wx:channel-pub-api-wx.test
}
7. Execute Vagrant again
PS E:\wwwroot\channel-pub-api> vagrant up Vagrant failed to initialize at a very early stage: There is a syntax error in the following vagrantfile. Message is reproduced below for convenience: E:/WWWRoot/Channel-PUB-API/VagrantFile:15: Syntax Error, Unexpected Tidentifier, Expecting} weibo:channel-pub-api-weibo.te ^ PS E:\wwwroot\channel-pub-api> vagrant up installing thevagrant-vbguestPlugin. This can take a few minutes... fetching: micromachine-2.0.0.gem (100%) fetching: vagrant-vbguest-0.16.0.gem (100%) installed the pluginvagrant-vbguest (0.16.0)! PS E:\wwwroot\channel-pub-api> vagrant usage: vagrant[options]<command>[<args>] -v, --version print the version and exit. -h, --help print this help. common commands: Box management boxes: Installation, Removal, etc. Cloud management everything related to vagrant cloud Destroy stops and deletes all traces of the Vagrant machine Global-status outputs status vagrant environments for this user Halt stops the vagrant machine Help Shows the Help for a Subcommand HostManager plugin: vagrant-hostmanager: management the /etc/hosts file within a multi-machine environment init initializes a new vagrant environment by creating a vagrantfile Login Package packages a running vagrant environment into a box Plugin management plugins: install, uninstall, update, etc. Port Displays Information About Guest Port Mappings PowerShell Connects to Machine via PowerShell Remoting Provisions The Vagrant Machine push deploys code in this environment to a configured destination RDP Connects to Machine Via RDP Reload restarts vagrant machine, loads new vagrantfile configuration Resume Resume A Suspended Vagrant Machine Snapshot management snapshots: Saving, Restoring, etc. ssh connects to machine via ssh ssh-config outputs openssh valid configuration to connect to the machine Status outputs Suspend Suspends The Machine Up Starts and Provisions The Vagrant Environment Upload Upload to Machine Via Communicator Validate validates the vagrantfile VBGuest Plugin: vagrant-vbguest: install virtualbox guest additions to the machine Version prints current and latest vagrant version WinRM Executes commands on a machine via WinRM WinRM-config outputs winRM configuration to connect to the machine For help on any individual command run `vagrant command -h` Additional subcommands are available, but are more advanced or not commonly used. to see all subcommands, run the command `vagrant list-commands`.
8. Create a virtual machine and execute the following commands
PS E:\wwwroot\channel-pub-api> vagrant up ==> channel-pub-api: machinechannel-pub-apiHas a post `vagrant up` message. This is a message ==> channel-pub-api: from the creator of the vagrantfile, and not from vagrant itself: ==> channel-pub-api: ==> channel-pub-api: frontend URL: http://channel-pub-api-frontend.test ==> channel-pub-api: backend URL: http://channel-pub-api-backend.test ==> channel-pub-api: api url: http://channel-pub-api-api.test ==> channel-pub-api: qq url: http://channel-pub-api-qq.test ==> channel-pub-api: rpc URL: http://channel-pub-api-rpc.test ==> channel-pub-api: weibo url: http://channel-pub-api-weibo.test ==> channel-pub-api: wx url: http://channel-pub-api-wx.test
9. After waiting for completion, just access the following URL in the browser, which is in line with the expectations
192.168.83.147 channel-pub-api-frontend.test 192.168.83.147 channel-pub-api-backend.test 192.168.83.147 channel-pub-api-api.test 192.168.83.147 channel-pub-api-qq.test 192.168.83.147 channel-pub-api-rpc.test 192.168.83.147 channel-pub-api-weibo.test 192.168.83.147 channel-pub-api-wx.test

