You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu Jammy下Vagrant迁移至libvirt时遇rexml加载失败求助

从VirtualBox迁移至libvirt时Vagrant-libvirt依赖缺失及SSL证书问题

问题背景

从VirtualBox迁移到libvirt,同事在Debian环境测试正常,但在Ubuntu 22.04上遇到无法解决的启动问题。

问题描述

复现步骤

git clone git@github.com:robinportigliatti/libvirt-test.git
cd libvirt-test
make up

报错信息

Bringing machine 'host1' up with 'libvirt' provider...
Traceback (most recent call last):
    21: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
    20: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `action'
    19: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:201:in `call'
    18: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/environment.rb:613:in `lock'
    17: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:215:in `block in action'
    16: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/machine.rb:243:in `action_raw'
    15: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `run'
    14: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/util/busy.rb:19:in `busy'
    13: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/runner.rb:89:in `block in run'
    12: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builder.rb:149:in `call'
    11: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
    10: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
     9: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
     8: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/box_check_outdated.rb:31:in `call'
     7: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/warden.rb:48:in `call'
     6: from /opt/vagrant/embedded/gems/2.2.10/gems/vagrant-2.2.10/lib/vagrant/action/builtin/call.rb:47:in `call'
     5: from /home/robin/.vagrant.d/gems/2.6.6/gems/vagrant-libvirt-0.9.0/lib/vagrant-libvirt/action.rb:99:in `block (2 levels) in action_up'
     4: from /opt/vagrant/embedded/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     3: from /opt/vagrant/embedded/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
     2: from /home/robin/.vagrant.d/gems/2.6.6/gems/vagrant-libvirt-0.9.0/lib/vagrant-libvirt/action/resolve_disk_settings.rb:4:in `<top (required)>'
     1: from /opt/vagrant/embedded/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/opt/vagrant/embedded/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rexml (LoadError)

预期结果

host1虚拟机正常启动

环境信息

  • Libvirt版本:
Compiled against library: libvirt 8.0.0
Using library: libvirt 8.0.0
Using API: QEMU 8.0.0
Running hypervisor: QEMU 6.2.0
  • Vagrant版本:
Installed Version: 2.2.10
Latest Version: 2.2.19
  • 系统版本:Ubuntu 22.04 LTS(Jammy)
  • Vagrant插件版本:
vagrant-libvirt (0.9.0, global)
vagrant-vbguest (0.30.0, global)

已尝试操作

  • 曾安装Ruby 3.0,现已移除,当前仅使用Vagrant内置Ruby 2.6.6
  • 执行/opt/vagrant/embedded/bin/gem install rexml安装依赖,遇SSL证书验证错误,提示缺少GlobalSign Root CA - R3证书
  • 更新系统证书,问题未解决

解决建议

方法1:绕过SSL验证安装rexml

执行命令临时跳过SSL验证,直接安装依赖:

/opt/vagrant/embedded/bin/gem install rexml --no-verify-certificate

方法2:修复Vagrant内置Ruby的SSL证书

  1. 复制系统CA证书到Vagrant证书目录:
sudo cp /etc/ssl/certs/GlobalSign_Root_CA_-_R3.pem /opt/vagrant/embedded/ssl/certs/
  1. 更新证书索引:
cd /opt/vagrant/embedded/ssl/certs/
sudo c_rehash
  1. 重新安装rexml:
/opt/vagrant/embedded/bin/gem install rexml

方法3:升级Vagrant版本

Vagrant 2.2.10版本较旧,升级到最新版本可修复部分依赖和SSL兼容问题,直接下载对应版本安装即可。

方法4:升级vagrant-libvirt插件

当前插件版本与Vagrant、Ubuntu环境可能存在兼容性问题,执行命令升级插件:

vagrant plugin update vagrant-libvirt

内容的提问来源于stack exchange,提问作者robinthebird

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 16:15:38