vagrant up报错【io.rb:32:in `encode': "\x95" followed by "\"" on GBK (Encoding::InvalidByteSequenceError)】
vagrant up报错【io.rb:32:in `encode': "\x95" followed by """ on GBK (Encoding::InvalidByteSequenceError)】
这几天在学习虚拟机的相关知识,在使用VirtualBox和Vagrant创建虚拟机时踩了一些坑,在网上搜索到的解决方案虽然给了我一些帮助,但是没有完全解决问题。现在就将我的问题记录下来,希望给新入坑的人一些帮助。
第一步,安装VirtualBox和Vagrant。没啥问题,顺利进行(注意:安装VirtualBox之前要开启电脑的虚拟化,这里就不在赘述了)
第二步,也没有问题
C:\Users\qiyue>vagrant init centos7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
/**
*由于vagrant是国外的网站,直接使用vagrant up由于网速太慢大概率会失败,所以我先将centos7.box
*下载下来通过命令添加
*/
C:\Users\qiyue>vagrant box add --name centos7 d:\guliSoft\centos7.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'centos7' (v0) for provider:
box: Unpacking necessary files from: file:///d:/guliSoft/centos7.box
box:
==> box: Successfully added box 'centos7' (v0) for 'virtualbox'!
注意:如果只使用vagrant init命令在后面vagrant up会报错
default: Box 'base' could not be found. Attempting to find and install...
C:\Vagrant>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'base' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'base' (v0) for provider: virtualbox
default: Downloading: base
default:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
这时候就需要你手动去改用户目录下的.Vagrantfile文件,使用记事本打开它,将config.vm.box = "base"中的base改成你给你的虚拟环境起的名称。这个问题就这样解决了。
第三步:
D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/io.rb:32:in `encode': "\xA3\x8E" from GBK to UTF-8 (Encoding::UndefinedConversionError)
C:\Users\七月的风>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos7'...
D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/io.rb:32:in `encode': "\xA3\x8E" from GBK to UTF-8 (Encoding::UndefinedConversionError)
from D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/io.rb:32:in `read_until_block'
from D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/subprocess.rb:242:in `block in execute'
from D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/subprocess.rb:240:in `each'
这里就是我们踩的第一个坑:
这里从网上百度很容易知道,是由于C:\Users\七月的风>这个目录下混入了中文导致的,然后我们将这里改成C:\Users\qiyue>,然后重新vagrant up发现还是报同样的错误,这是为什么呢。

解决方案:经过一番琢磨我发现,虽然我将路径目录全改成了英文,但是这几个文件是在中文目录下生成的,所以检测到的还是中文,所以还会报乱码错误。所以我索性将这几个文件全删除了,然后将软件卸载了,重新安装。一切ok。

如果你还出现了下面这种报错:
D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/io.rb:32:in `encode': "\x95" followed by """ on GBK (Encoding::InvalidByteSequenceError)
解决方案:这时候你要到D:/guliSoft/HashiCorp/Vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/io.rb目录下找到地32行,将这行注释掉,下面加入参考github上的代码。
#data << io.readpartial(READ_CHUNK_SIZE).encode("UTF-8", Encoding.default_external)
data << io.readpartial(READ_CHUNK_SIZE).encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')
然后vagrant up就大功告成了

vagrant up报错【io.rb:32:in `encode': "\x95" followed by "\"" on GBK (Encoding::InvalidByteSequenceError)】的更多相关文章
- win7环境下,vagrant,在启动虚拟机的时候报错io.rb:32:in `encode': incomplete "\xC8" on GBK (Encoding::InvalidByteSequenceError)
描述: 这几天在windows环境上,部署了vagrant,在启动虚拟机的时候报错: [c:\~]$ vagrant upBringing machine 'default' up with 'vir ...
- Python3 报错'latin-1' codec can't encode character 解决方案
Python3 报错'latin-1' codec can't encode character 解决方案 在更新数据库操作时,报错: UnicodeEncodeError: 'latin-1' co ...
- vagrant启动报错The following SSH command responded with a no
vagrant package打包生成box,以这个box为基础模板,打造vagrant环境,启动vagrant报错 angel:vagrant $ vagrant up Bringing machi ...
- netty-websocket-spring-boot-starter关闭报错 io/netty/channel/AbstractChannel$AbstractUnsafe io/netty/util/concurrent/GlobalEventExecutor
报错 java.lang.NoClassDefFoundError: io/netty/channel/AbstractChannel$AbstractUnsafe$ at io.netty.chan ...
- .NET Window服务启动又马上停止,报错IO.FileNotFoundException
最近公司需要开发一个Window服务推送系统,读取MongoDB写入消息队列,推送到各终端平台 但是在开发完成,最后的部署阶段,选中服务右击启动 看似正常,服务显示已启动(但实质已经被终止,因为Win ...
- springboot2集成redis5报错:io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: DENIED Redis is running in protected
报错信息如下: Caused by: io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: DENIED ...
- vagrant up报错 Warning: Authentication failure. Retrying...解决方案
参照链接 https://www.cnblogs.com/zqifa/p/vagrant-1.html 可以解决问题.
- Homestead 修改 Homestead.yaml 文件后 vagrant up 报错的问题
一般情况是 TAB 和空格的问题. 虽然表面看来,缩进是一致的. 但是 TAB 没能替换为空格,从而导致问题. 解决: $ sudo vim /etc/vim/vimrc.local syntax o ...
- python里面出现中文的时候报错 'ascii' codec can't encode characters in position
编码问题,在头部添加 import sys reload(sys) sys.setdefaultencoding( "utf-8" ) http://www.xuebuyuan.c ...
随机推荐
- Kubernetes【K8S】(四):资源控制器
什么是控制器 Kubernetes中内建了很多controller(控制器),这些相当于一个状态机,用来控制Pod的具体状态和行为. 控制器类型 ReplicationController和Rep ...
- Python SQLALchemy框架
SQLALchemy SQLALchemy是Python中的一款优秀的ORM框架,它可以作用于任何第三方Web框架,如flask,tornado等框架. SQLALchemy相较于DjangoORM来 ...
- js上 三、数据类型
3.1.什么是数据类型 a. 什么是数据类型? 想从生活中出发: 考验智商的时刻到了: 1(只)+1(只)=1(双) 3(天)+4(天)=1(周) 5(月)+7(月)=1(年) 4(时)+9(时)=1 ...
- [水题日常]UVA1625 Color Length
来整理一下思路- 一句话题意:给两个大写字母的序列,每次取出其中一个数列的第一个元素放到新序列里面,对每个字母\(c\)记它的跨度\(L(c)\)为这个字母最后出现的位置-第一次出现的位置,求新序列所 ...
- Java_day_01
一.方法的定义 方法的定义在Java中可以使用多种方式,如果在定义的方法名前面加上 public static 关键字,即可直接在主方法(main)中调用 public class Method{ p ...
- 记录一下网上找到的别人写的angualr总结
感觉写的不错,所以讲链接保存下来 https://www.jianshu.com/p/f0f81a63cbcb
- 用Python实现童年的回忆:俄罗斯方块!别说还挺好玩
在那个电子产品比较匮乏的年代,小游戏机
- 【探索之路】机器人篇(1)-ROS-mwRobot开篇
机器人的定义 首先,什么才是机器人?机器人是不是必须和人一样的外形?我们先看一看维基百科给机器人的定义: 由上可见,机器人并不是和人一样的外形,而是可以模拟人类行为或者思想再或者是模拟其他生物的机械. ...
- CentOS 8 安装Nginx
安装命令: dnf install nginx -y 这就安装完成了 ,对你没看错一个命令就已经把nginx安装好了,不信你通过 nginx -V 命令查看. 常用操作: 1.nginx配置文件目录 ...
- 在 ASP.NET Core和Worker Service中使用Quartz.Net
现在有了一个官方包Quartz.Extensions.Hosting实现使用Quartz.Net运行后台任务,所以把Quartz.Net添加到ASP.NET Core或Worker Service要简 ...