标题 2019-06-30
最近vagrant不知道什么原因无法启动,日志如下:
Bringing machine 'default' up with 'virtualbox' provider...
/Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/io.rb:32:in `encode': "x8B" followed by "x02" on GBK (Encoding::InvalidByteSequenceError)
from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/io.rb:32:in `read_until_block' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/subprocess.rb:194:in `block in execute' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/subprocess.rb:192:in `each' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/subprocess.rb:192:in `execute' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/subprocess.rb:22:in `execute' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/powershell.rb:174:in `version' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/powershell.rb:195:in `validate_install!' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/powershell.rb:96:in `execute_cmd' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/platform.rb:145:in `block (2 levels) in windows_hyperv_enabled?' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/platform.rb:142:in `each' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/platform.rb:142:in `block in windows_hyperv_enabled?' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/platform.rb:153:in `windows_hyperv_enabled?' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/plugins/providers/virtualbox/action/check_virtualbox.rb:19:in `call' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/action/warden.rb:34:in `call' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/action/builder.rb:116:in `call' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/action/runner.rb:66:in `block in run' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/util/busy.rb:19:in `busy' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/action/runner.rb:66:in `run' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/machine.rb:239:in `action_raw' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/machine.rb:208:in `block in action' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/environment.rb:614:in `lock' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/machine.rb:194:in `call' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/machine.rb:194:in `action' from /Vagrant/embedded/gems/2.2.1/gems/vagrant-2.2.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'
参考了两篇网上找到文章,无法解决问题
1 日文网站的解决方案(**认为是编码问题**):https://github.com/NetCommons3/NetCommons3/issues/50 対策 「C:\opscode\chefdk\bin\berks」 を開き、3行目に Encoding.default_external = 'utf-8' 2 laravel-china上的一篇文章(**认为是中文问题**),很相似,可是问题原因不同。但也给了解决思路 https://laravel-china.org/articles/4082/a-wonderful-problem-encountered-in-the-use-of-vagrant
随后自己仔细看了下ruby的日志及相关源码,发现里面描述了powershell的问题,于是尝试启动windows的powershell果然是启动失败。
这样的话问题就好说了,解决了powershell的问题就行了。(是.netFramework的问题,原来是自己之前由于visio安装不上,升级了.netFramework)。降级.netFramework即可
之后Vagrant启动正常
总结:遇到问题注意看日志,尽管是自己不熟悉的语言。
文章结尾奶一下ruby:
借用《Programming Ruby》推荐序中的一段话: 事实上,执行性能与开发效率是软件开发中的一对矛盾,所有的程序设计语言都必须面对这个矛盾,作出自己的选择。 在当时,大多数新语言的选择是上下通吃。它们一方面提供了丰富多彩的高级抽象,另一方面又提供了强有力的底层操作能力,希望由此实现高性能与高效率的统一。 C++、Java、C#和Delphi都是走的这条路线,甚至VB从5.0开始也强化了底层操作机制,并提供了编译模型,不落人后。 Ruby实现了最纯粹意义上的面向对象,让Smalltalk、Perl和Lisp的灵魂在新的躯壳里高歌。 相比于Python,Ruby的思想更加清晰一致,形式更加灵活; 相比于Perl,Ruby更简单质朴,绝少光怪陆离之举; 相比于Smalltalk和Lisp,Ruby更富有现代感和实干气质; 相比于庙堂之上的“工业语言”,Ruby自由挥洒、轻快锐利; 而相比于JavaScript和PHP,Ruby从Smalltalk继承而来的深厚底蕴又大占优势。 面对执行性能与开发效率的谜题,Ruby毫不犹豫地选择了开发效率,选择了对人脑的友好。
Created by suyaqiang ([email protected]) on 2019/1/20.