Vagrant: Vagrant 2.1.4 breaks plugin detection / install script

Created on 5 Sep 2018  ·  9Comments  ·  Source: hashicorp/vagrant

Vagrant version

Vagrant 2.1.2 (downgraded) / Vagrant 2.1.4

Host operating system

Linux 4.18.5-arch1-1-ARCH

Guest operating system

N/A

Vagrantfile

# Handle installation of external plugins required for this Vagrantfile to work
required_plugins = %w(
  vagrant-s3auth
  vagrant-sshfs
)
needs_restart = false
toplevel_dir = File.dirname(File.expand_path(__FILE__))
required_plugins.each do |plugin|
  # Install any required plugins that are missing
  unless Vagrant.has_plugin? plugin
    # Plugin is not installed yet, so attempt to install it now.  Bail out on
    # failure so we don't get stuck in an infinite loop.
    # :chdir added to avoid recursively loading this file while loading plugins (https://github.com/hashicorp/vagrant/issues/9972)
    system("vagrant plugin install #{plugin} --plugin-clean-sources --plugin-source file://#{toplevel_dir}/vagrant/gems", :chdir => "/tmp") || exit!
    needs_restart = true
  end
end
if needs_restart
  # Relaunch Vagrant so the plugin is detected. Exit with the same status code.
  exec "vagrant #{ARGV.join' '}"
end

Debug output

https://gist.github.com/JohnMaguire/a0ad03c37dcb57e09fc37d9689d47ce8 (Hit C-c after a few seconds)

Expected behavior

VM brought up (as Vagrant 2.1.2 does)

Actual behavior

Plugin install loop:

Installing the 'vagrant-s3auth' plugin. This can take a few minutes...
Installed the plugin 'vagrant-s3auth (1.3.2)'!
Installing the 'vagrant-sshfs' plugin. This can take a few minutes...
Installed the plugin 'vagrant-sshfs (1.3.0)'!
Installing the 'vagrant-s3auth' plugin. This can take a few minutes...
Installed the plugin 'vagrant-s3auth (1.3.2)'!
Installing the 'vagrant-sshfs' plugin. This can take a few minutes...
Installed the plugin 'vagrant-sshfs (1.3.0)'!
Installing the 'vagrant-s3auth' plugin. This can take a few minutes...
bug regression

All 9 comments

I'm seeing this error which I believe to be the same issue:

-----> Creating <config-access-cub-rh7>...
       Vagrant failed to initialize at a very early stage:

       There was an error loading a Vagrantfile. The file being loaded
       and the error message are shown below. This is usually caused by
       a syntax error.

       Path: /home/jay/local/data/sis/git/cookbooks/cub_shibboleth/.kitchen/kitchen-vagrant/config-access-cub-rh7/Vagrantfile
       Line number: 20
       Message: NameError: uninitialized constant VagrantPlugins::Registration

(The file /home/jay/local/data/sis/git/cookbooks/cub_shibboleth/.kitchen/kitchen-vagrant/config-access-cub-rh7/Vagrantfile is managed by TestKitchen and was deleted soon after so unfortunately I don't have a copy to share right now, but I it referenced VagrantPlugins::Registration so that it could configure Red Hat licensing at VM creation time)

no such error on Vagrant 2.1.2, and the vagrant-registration plugin is reported as being installed:

[birdsnest ~/Work/git/cookbooks/cub_shibboleth](INC0493293|✚2)[I]% vagrant plugin list
vagrant-registration (1.3.1, global)
vagrant-triggers (0.5.3, global)

I'm seeing the same symptoms as the original report.

Vagrant version 2.1.4
macOS High Sierra 10.13.6

Same here
2.1.4 on Windows 10
uninstalled 2.1.4 and installed 2.1.2; still fails.

Vagrant version 2.1.4
MacOS High Sierra 10.13.6

vagrant up
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.16.0)'!
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.8.9)'!
Installing plugins: vagrant-vbguest vagrant-hostmanager
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...

There was block of code in my VagrantFile which was forcing to install plugins, somehow it looks creating problem. I commented it to out and that fixed the issue

## Install plugins from the required_plugins list
required_plugins = %w( vagrant-vbguest vagrant-hostmanager )
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
  puts "Installing plugins: #{plugins_to_install.join(' ')}"
  if system "vagrant plugin install #{plugins_to_install.join(' ')}"
    exec "vagrant #{ARGV.join(' ')}"
  else
    abort "Installation of one or more plugins has failed. Aborting."
  end
end

maybe also related to https://github.com/hashicorp/vagrant/issues/10186
could be that because of the double loading of the vagrantfile some (environment) variables are not set, which maybe also could lead to this problem.

Same issue on

Vagrant version 2.1.4
macOS High Sierra 10.13.6

Fixed by #10199

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cbeck527 picture Cbeck527  ·  3Comments

rrzaripov picture rrzaripov  ·  3Comments

dorinlazar picture dorinlazar  ·  3Comments

RobertSwirsky picture RobertSwirsky  ·  3Comments

barkingfoodog picture barkingfoodog  ·  3Comments