Vagrant 如何从文件中检测是否安装了插件?

Vagrant 如何从文件中检测是否安装了插件?,vagrant,Vagrant,我想检测是否安装了插件,以便为用户添加一些有用的调试提示 我尝试了以下代码: if config.vbguest config.vbguest.auto_update = true else puts "installing vagrant-vbguest plugin is recommended" end 但是,Vagrant输出*未知配置部分“vbguest”。 是否有一种方法可以检测插件是否已安装?如果插件已安装,该方法将返回true 例如: unless

我想检测是否安装了插件,以便为用户添加一些有用的调试提示

我尝试了以下代码:

  if config.vbguest
    config.vbguest.auto_update = true
  else
    puts "installing vagrant-vbguest plugin is recommended"
  end
但是,Vagrant输出
*未知配置部分“vbguest”。

是否有一种方法可以检测插件是否已安装?

如果插件已安装,该方法将返回true

例如:

unless Vagrant.has_plugin?("vagrant-some-plugin")
  raise 'some-plugin is not installed!'
end
原始来源: