Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Undefined HashMap method except with Vagrant 2.2.7 #566

Open
externl opened this issue Jan 31, 2020 · 23 comments · May be fixed by #575
Open

Undefined HashMap method except with Vagrant 2.2.7 #566

externl opened this issue Jan 31, 2020 · 23 comments · May be fixed by #575

Comments

@externl
Copy link

externl commented Jan 31, 2020

/Users/jenkins/.vagrant.d/gems/2.4.9/gems/vagrant-aws-0.7.2/lib/vagrant-aws/action/connect_aws.rb:41:in `call': undefined method `except' for #<Hash:0x0000000101596148> (NoMethodError)
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/warden.rb:57:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/builtin/before_trigger.rb:23:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/warden.rb:57:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/builtin/after_trigger.rb:26:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/warden.rb:57:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/warden.rb:57:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/builtin/before_trigger.rb:23:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/warden.rb:57:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/builder.rb:116:in `call'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/runner.rb:102:in `block in run'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/util/busy.rb:19:in `busy'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/action/runner.rb:102:in `run'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:238:in `action_raw'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:209:in `block in action'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:191:in `block in action'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:195:in `action'
	from /Users/jenkins/.vagrant.d/gems/2.4.9/gems/vagrant-aws-0.7.2/lib/vagrant-aws/provider.rb:32:in `state'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:532:in `state'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/machine.rb:146:in `initialize'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/vagrantfile.rb:81:in `new'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/vagrantfile.rb:81:in `machine'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/environment.rb:715:in `machine'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/plugin/v2/command.rb:213:in `block in with_target_vms'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/plugin/v2/command.rb:212:in `map'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/plugin/v2/command.rb:212:in `with_target_vms'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/plugins/commands/status/command.rb:20:in `execute'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/cli.rb:66:in `execute'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/lib/vagrant/environment.rb:290:in `cli'
	from /opt/vagrant/embedded/gems/2.2.7/gems/vagrant-2.2.7/bin/vagrant:182:in `<main>'

Looks like activesupport is now missing. Maybe it was bundled with vagrant it previous version?

@externl externl changed the title Errors with Vagrant 2.2.7 Undefined HashMap method except with Vagrant 2.2.7 Jan 31, 2020
@externl
Copy link
Author

externl commented Jan 31, 2020

Actually nothing to do with activesupport. It looks like a change to the i18n package which was upgraded with Vagrant 2.2.7.

They originally provided Hash.except: https://github.com/ruby-i18n/i18n/blob/1e67c8dd80933703328be524d3d8c4f21cb8c5a3/lib/i18n/core_ext/hash.rb

Now it's https://github.com/ruby-i18n/i18n/blob/741add9dba3fe8189454f47c5774b45211ab11a9/lib/i18n/core_ext/hash.rb

A quick fix for anyone experiencing this issue is to place the following in your ~/.vagrant/Vagrantfile

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
    h
  end unless Hash.method_defined?(:slice)
  def except(*less_keys)
    slice(*keys - less_keys)
  end unless Hash.method_defined?(:except)
end

Vagrant.configure(2) do |config|
...

@khaledavarteq
Copy link

I've also seen this bug after upgrading to Vagrant 2.2.7. I downgraded to Vagrant 2.2.5 as a quick fix. I did not try @externl 's Quick fix yet.

@obilodeau
Copy link

I can confirm that @externl's workaround works.

Vagrant 2.2.7, ruby 2.7.0p0, Arch Linux.

@cre8tions
Copy link

I can confirm that @externl's workaround works.

Vagrant 2.2.7 Win10

@jjn1056
Copy link

jjn1056 commented Mar 23, 2020

Getting this issue as well. I just edited 'vagrant-aws/action/connect_aws.rb' line 41 to remove the 'except' call. That gave me lots of warnings but just seemed to work. I would think this is easy to fix no?

@hundredacres
Copy link

Can confirm the fix from @externl works as well.

@lapchynski
Copy link

lapchynski commented Apr 30, 2020

Fix from @externl works for me as well. Ubuntu 18.04, Vagrant 2.2.7

ssapra pushed a commit to cloudfoundry/bosh-agent that referenced this issue May 13, 2020
See mitchellh/vagrant-aws#566

Since we test the bosh-agent against linux and windows, we started
testing against go1.14 on windows and go1.13 on linux. I decided to
update the bosh-agent linux docker image to install go1.14.

The new docker image brought Ruby 2.5+ was installed and vagrant-aws needed to be updated.
I decided to keep going and update the plugin
(d6d7ba9).

This led to this error with vagrant-aws and Ruby's i18n. I could undo
all of this by pinning Ruby in our docker image so that none of these
dependencies are updated, but I think the risk of keeping this
monkeypatch around for a bit is fine.
@soulhunter
Copy link

Actually... what @externl said... if you add it near the top of connect_aws.rb seems to workaround (or maybe fix?) the issue. I opened ~/.vagrant.d/gems/2.6.6/gems/vagrant-aws-0.7.2/lib/vagrant-aws/action/connect_aws.rb and added, per @externl, just after the two require lines:

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
    h
  end unless Hash.method_defined?(:slice)
  def except(*less_keys)
    slice(*keys - less_keys)
  end unless Hash.method_defined?(:except)
end

I have not studied the problem more in-depth. I just tried with vagrant 2.2.9 and plugin version 0.7.2.

@externl
Copy link
Author

externl commented Jun 2, 2020

The issue is that vagrant core upgraded a plugin which this project depends. Unfortunately the only real fix is for @mitchellh to fix or accept a PR fixing it.

The usage of except needs to be remove here.

@guzzijones
Copy link

somebody must have forked and fixed this.

@soulhunter
Copy link

@guzzijones I wonder if they abandoned this project :( ... I was considering forking it and review/apply the fixes I can see here... there are a few pull requests open. However, I do not use this nearly enough as to justify the time investment. I hope @mitchellh is ok.

@jolohaga
Copy link

A less intrusive way I've found works is putting @externl's solution in a separate file and adding to the Vagrantfile require_relative 'initializers/patches.rb'

al-the-x added a commit to al-the-x/vagrant-aws that referenced this issue Aug 20, 2020
Since `Hash#except` is not in standard Ruby and Vagrant removed `active_support` that provides the polyfill.

Resolves mitchellh#566
@al-the-x
Copy link

Dunno if we can get one of the maintainers to merge this, but at least here's a minimal patch that should work. Testing it locally now. (FYI, @mitchellh seems like he might be busy running something...)

mattock added a commit to Puppet-Finland/puppet-librenms that referenced this issue Sep 1, 2020
@liangbin-pub
Copy link

Why is this issue still not fixed, I saw it with 2.2.10 and mattock workaround still works

@ralfbetazi
Copy link

I have also encountered this issue in 2.2.10 just like @liangbin-pub (on MacOS Catalina 10.15.7)

mattock pushed a commit to Puppet-Finland/puppet-puppetmaster that referenced this issue Oct 31, 2020
mkubenka added a commit to mkubenka/vagrant-aws that referenced this issue Nov 3, 2020
Since Hash#except is not in standard Ruby and Vagrant removed active_support i18n that provides the polyfill in Vagrant 2.2.7; even the polyfill was just Hash#slice minus the requested keys. Seemed simpler to inline than monkey-patch Hash...

Resolves mitchellh#566

Based on mitchellh#575
@mkubenka
Copy link

mkubenka commented Nov 3, 2020

As a temporary solution you can use my Gem vagrant-aws-mkubenka with fix based on #575.

Installation instructions:

vagrant plugin uninstall vagrant-aws
vagrant plugin install vagrant-aws-mkubenka --plugin-version "0.7.2.pre.24"

@derks
Copy link

derks commented Nov 19, 2020

Same issue, fix from @externl works for me as well on:

  • Vagrant: 2.2.13
  • AWS Plugin: 0.7.2

@aorel08
Copy link

aorel08 commented Nov 23, 2020

Same issue and @externl 's with @soulhunter 's updates works like a charm on:

  • Vagrant 2.2.14
  • AWS Plugin 0.7.2

elconde pushed a commit to elconde/vagrant-aws that referenced this issue Nov 30, 2020
matt-richardson added a commit to OctopusDeploy/OctopusDSC that referenced this issue Jan 18, 2021
matt-richardson added a commit to OctopusDeploy/OctopusDSC that referenced this issue Jan 18, 2021
mariash added a commit to cloudfoundry/bosh-agent that referenced this issue Feb 2, 2021
See mitchellh/vagrant-aws#566
We were getting this error in our integration tests. It seems there is an
issue introduced in vagrant 2.2.7. We need at least version 2.2.8 for
another fix.

Co-authored-by: Kenneth Lakin <[email protected]>
Co-authored-by: Maria Shaldybin <[email protected]>
LeePorte pushed a commit to alphagov/paas-bootstrap that referenced this issue Feb 15, 2021
We had let this bitrot and it required using an old version of Vagrant.
Unfortunatly there is the need to put in a hack due to this issue on the
vagrant-aws provider
mitchellh/vagrant-aws#566. I suspect that this
provider is now abandoned as there is even a PR open to fix it
mitchellh/vagrant-aws#575. I propose that we
look to remove vagrant in the not too distant future.
LeePorte pushed a commit to alphagov/paas-bootstrap that referenced this issue Feb 16, 2021
We had let this bitrot and it required using an old version of Vagrant.
Unfortunatly there is the need to put in a hack due to this issue on the
vagrant-aws provider
mitchellh/vagrant-aws#566. I suspect that this
provider is now abandoned as there is even a PR open to fix it
mitchellh/vagrant-aws#575. I propose that we
look to remove vagrant in the not too distant future.
@nand0p
Copy link

nand0p commented Feb 17, 2021

is this broken on purpose to make vagrant hard to use?

require_relative worked for me.

@eXist73
Copy link

eXist73 commented Apr 2, 2021

@externl Thanks, worked for me as well.

@mpictor
Copy link

mpictor commented Jun 15, 2021

Reported 1.5 years ago and still broken in the latest version (a fresh install) of vagrant. 😞

$ vagrant --version
Vagrant 2.2.16
$ vagrant status
~/.vagrant.d/gems/2.6.7/gems/vagrant-aws-0.7.2/lib/vagrant-aws/action/connect_aws.rb:41:in `call': undefined method `except' for #<Hash:0x0000000002591a80> (NoMethodError)
        from /opt/vagrant/embedded/gems/2.2.16/gems/vagrant-2.2.16/lib/vagrant/action/warden.rb:48:in `call'
...

@externl
Copy link
Author

externl commented Jun 15, 2021

There hasn't been a new release since Jul 3, 2016. I think it's safe to say that this project has been abandoned.

ricamos added a commit to ricamos/vagrant_aws that referenced this issue Sep 24, 2021
Erro ao executar vagrant up --provider=aws.
Solução adicionar as seguintes linhas ao vagrante file:

class Hash
  def slice(*keep_keys)
    h = {}
    keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
    h
  end unless Hash.method_defined?(:slice)
  def except(*less_keys)
    slice(*keys - less_keys)
  end unless Hash.method_defined?(:except)
end

Solução foi encontrada nas referências abaixo.

mitchellh/vagrant-aws#568
mitchellh/vagrant-aws#566

 On branch master
 Changes to be committed:
	modified:   README.md
	modified:   Vagrantfile
@StephenTan-TW
Copy link

there are still use cases for this! Why can't we get a new release? Not everyone is using Kubernetes and/or Docker for everything!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.