账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vagrant up启动报错编码问题
    50
    0
    C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/windows/process_builder.rb:44:in `encode!': "\xE5" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to UTF-16LE (Encoding::UndefinedConversionError) from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/windows/process_builder.rb:44:in `to_wide_string' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/windows/process_builder.rb:67:in `create_environment_pointer' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/windows/process_builder.rb:28:in `start' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/windows/process.rb:70:in `launch_process' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/childprocess-4.1.0/lib/childprocess/abstract_process.rb:81:in `start' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/subprocess.rb:155:in `block in execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/safe_chdir.rb:26:in `block (2 levels) in safe_chdir' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/safe_chdir.rb:25:in `chdir' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/safe_chdir.rb:25:in `block in safe_chdir' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/safe_chdir.rb:24:in `synchronize' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/safe_chdir.rb:24:in `safe_chdir' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/subprocess.rb:154:in `execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/subprocess.rb:22:in `execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/base.rb:466:in `block in raw' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/busy.rb:19:in `busy' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/base.rb:465:in `raw' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/base.rb:403:in `block in execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/retryable.rb:17:in `retryable' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/base.rb:398:in `execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/meta.rb:177:in `block in read_version' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/util/retryable.rb:17:in `retryable' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/meta.rb:176:in `read_version' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/meta.rb:46:in `block in initialize' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/meta.rb:41:in `synchronize' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/driver/meta.rb:41:in `initialize' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/provider.rb:21:in `new' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/providers/virtualbox/provider.rb:21:in `usable?' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/vagrantfile.rb:155:in `machine_config' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/vagrantfile.rb:47:in `machine' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:716:in `machine' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:204:in `block in with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:186:in `each' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/plugin/v2/command.rb:186:in `with_target_vms' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/plugins/commands/up/command.rb:87:in `execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/cli.rb:67:in `execute' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/lib/vagrant/environment.rb:290:in `cli' from C:/HashiCorp/Vagrant/embedded/gems/2.2.18/gems/vagrant-2.2.18/bin/vagrant:231:in `<main>'process_builder.rb文件第44行搜索的答案说是因为目录里有中文,但是之前用户也是中文一直都可以用,就今天突然不能用了,有没有大佬解答一下啊?
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 在Vagrant中,出现编码问题时,通常会导致Vagrant无法正确解析或执行脚本,这可能是因为你的宿主机上使用的编码与Vagrant的配置不匹配。以下是可能的解决方案:

      1. 确认编码设置
      2. 打开终端并进入你的Vagrant项目目录(vagrant up时默认路径为/vagrant)。
      3. 确认Vagrant使用的是你主机上使用的默认编码设置。在Vagrantfile中,通常有一个configdefault目录,其中包含config.vm.provisiondefault.provision文件,其中包含了环境变量设置,如VAGRANT_DEFAULTencoding。例如:

      ruby config.vm.provision 'VirtualBox', :charset => 'UTF-8'

      如果你在Vagrantfile中没有配置这个环境变量,你需要手动设置为UTF-8。如果你使用的是Windows系统,你可以设置为cp1252,如果你使用的是Linux系统,你可以设置为utf-8

      如果你的编码设置与Vagrant的配置不匹配,可能会导致编码无法解析或执行脚本。为了确定问题的具体位置,你可以尝试以下步骤:

      • 确保在config.vm.provisiondefault.provision文件中,环境变量VAGRANT_DEFAULTencoding正确地指向了你使用的编码。例如:

        ruby config.vm.provision 'VirtualBox', :charset => 'UTF-8', :defaultencoding => 'UTF-8'

      • 在终端中,执行vagrant provision命令,检查脚本是否正确执行。例如,如果你的Vagrantfile中有以下代码:

        ruby # Execute some commands

        现在在执行vagrant provision命令后,如果脚本成功执行并显示了错误消息,说明编码设置是正确的。如果脚本无法执行,可能是由于编码设置与实际环境不匹配导致的。此时,你需要检查你的宿主机是否支持所使用的编码,或者你是否将Vagrant设置为使用其他编码。

      • 如果上述步骤无法解决问题,尝试使用其他编码环境变量设置。例如:

        ruby config.vm.provision 'VirtualBox', :charset => 'GBK'

        这将设置为使用GBK编码环境变量。注意,GBK编码适用于中国和香港地区,如果你的宿主机或使用的文件系统使用的是其他编码,你可能需要使用相应的编码环境变量设置。

      • 如果以上步骤也无法解决问题,尝试重新安装Vagrant或你的Vagrantfile。有时,某些环境变量或脚本可能在特定版本或环境下无法正确配置,你可以通过以下步骤重新安装或修改Vagrant:

        • 如果你使用的是Vagrant 1.8.0或更高版本,你可以通过vagrant init <version>命令下载和安装新的Vagrant发行版,然后根据安装文档重新配置环境变量和脚本。例如,如果你的Vagrant版本是1.8.0,你可以执行以下命令:

          vagrant init 1.8.0

          在弹出的命令行界面中,选择你的宿主机和Vagrantfile,然后选择安装版本,最后点击安装。

        • 如果你的Vagrantfile是使用GEMFILE或Vagrantfile.rb,你可以通过在Vagrantfile中添加以下代码,来设置编码环境变量:

          ruby config.vm.provision 'VirtualBox', :charset => 'GBK'

          之后,你可以通过vagrant provision命令运行配置后的脚本。

      • 如果以上步骤都无法解决问题,尝试检查你的Vagrantfile中是否包含config.vagrant.common.vagrantfile文件,这是一个用于设置Vagrant默认配置的文件,其中包括了Vagrant的编码环境变量。如果Vagrantfile中包含这个文件,你可以检查其编码设置是否与Vagrant的配置一致,或者是否与你的宿主机上的编码设置不匹配。

      • 如果上述步骤也无法解决问题,你可能需要联系Vagrant的官方技术支持,他们可能会提供更具体的解决方案或指导。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部