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

执行vagrant init ubuntu/xenial64时缺失bcrypt_pbkdf gem报错求助

解决Vagrant执行vagrant init时的bcrypt_pbkdf缺失错误

在C:\VM\first_project目录下执行vagrant init ubuntu/xenial64时触发以下错误:

C:\VM\first_project>vagrant init ubuntu/xenial64
Traceback (most recent call last):
6: from C:/HashiCorp/Vagrant/embedded/gems/2.3.1/gems/vagrant-2.3.1/bin/vagrant:105:in `<main>'
5: from C:/HashiCorp/Vagrant/embedded/gems/2.3.1/gems/vagrant-2.3.1/bin/vagrant:94:in `block in <main>'
4: from C:/HashiCorp/Vagrant/embedded/gems/2.3.1/gems/vagrant-2.3.1/bin/vagrant:94:in `each'
3: from C:/HashiCorp/Vagrant/embedded/gems/2.3.1/gems/vagrant-2.3.1/bin/vagrant:95:in `block (2 levels) in <main>'
2: from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
1: from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'bcrypt_pbkdf' (~> 1.1) among 94 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/HashiCorp/Vagrant/embedded/gems/2.3.1', execute `gem env` for more information

错误核心是Vagrant依赖的bcrypt_pbkdf gem(版本要求~>1.1)未在指定GEM_PATH中找到,可通过以下步骤解决:

  • 使用Vagrant内置gem安装缺失包
    Vagrant自带独立Ruby环境,需调用其内置的gem工具安装,避免与系统gem冲突。执行以下命令:

    C:/HashiCorp/Vagrant/embedded/bin/gem install bcrypt_pbkdf -v '~>1.1'
    

    该命令会将符合版本要求的bcrypt_pbkdf安装到Vagrant的gem目录中。

  • 验证修复效果
    回到C:\VM\first_project目录,重新执行:

    vagrant init ubuntu/xenial64
    

    若无报错则问题解决。

  • 备选方案:重装Vagrant
    若上述方法无效,可能是Vagrant安装文件损坏。卸载当前2.3.1版本,重新下载对应版本的安装包完成安装后再尝试执行命令。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 21:55:22