Blob Blame History Raw
From e4859e2486a3ac031a79ae62ef17bd8cbdbb86e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Sun, 4 Apr 2021 22:46:45 +0200
Subject: [PATCH] Fix shell provisioner with ruby 3.0

I recently updated to Fedora 34 (which uses ruby 3.0), and `vagrant up` errors out like this:

```
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/ui.rb:230:in `say': wrong number of arguments (given 4, expected 2..3) (ArgumentError)
	from (eval):3:in `detail'
	from (eval):9:in `detail'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:79:in `handle_comm'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:127:in `block (3 levels) in provision_ssh'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:254:in `block (2 levels) in execute'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:617:in `block (3 levels) in shell_execute'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/channel.rb:598:in `do_extended_data'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:673:in `channel_extended_data'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:548:in `dispatch_incoming_packets'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:248:in `ev_preprocess'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/event_loop.rb:100:in `each'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/event_loop.rb:100:in `ev_preprocess'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/event_loop.rb:28:in `process'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:227:in `process'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:180:in `block in loop'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:180:in `loop'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/session.rb:180:in `loop'
	from /usr/share/gems/gems/net-ssh-6.1.0/lib/net/ssh/connection/channel.rb:272:in `wait'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:702:in `shell_execute'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:247:in `block in execute'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:391:in `connect'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/communicators/ssh/communicator.rb:240:in `execute'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:122:in `block (2 levels) in provision_ssh'
	from <internal:kernel>:90:in `tap'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:96:in `block in provision_ssh'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:329:in `with_script_file'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:94:in `provision_ssh'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/plugins/provisioners/shell/provisioner.rb:33:in `provision'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:138:in `run_provisioner'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/environment.rb:525:in `hook'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:126:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:126:in `block in call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:103:in `each'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/provision.rb:103:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:363:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain_volume.rb:89:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_box_image.rb:124:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
	from /usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
```

I'm not a ruby expert but I believe it's related to [this breaking change](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/). This change fixes it for me.
---
 plugins/provisioners/shell/provisioner.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb
index 08c8cf739d3..e95f176f28b 100644
--- a/plugins/provisioners/shell/provisioner.rb
+++ b/plugins/provisioners/shell/provisioner.rb
@@ -78,7 +78,7 @@ def handle_comm(type, data)
           options = {}
           options[:color] = color if !config.keep_color
 
-          @machine.ui.detail(data.chomp, options)
+          @machine.ui.detail(data.chomp, **options)
         end
       end
 
From c145867fdd4fb2767f73534057a7bdb9cad3468e Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Fri, 7 May 2021 01:52:27 +0200
Subject: [PATCH] Fix compatibility with Ruby 3.0

Currently it fails with Ruby 3.0:
```
  1) VagrantPlugins::Kernel_V2::VagrantConfigDisk#add_provider_config normalizes
provider config
     Failure/Error: subject.add_provider_config(test_provider_config)

     ArgumentError:
       wrong number of arguments (given 1, expected 0)
     # ./plugins/kernel_v2/config/disk.rb:88:in `add_provider_config'
     # ./test/unit/plugins/kernel_v2/config/disk_test.rb:122:in `block (3 levels)
in <top (required)>'
     # /usr/share/gems/gems/webmock-3.12.1/lib/webmock/rspec.rb:37:in `block (2
levels) in <top (required)>'
```
---
 test/unit/plugins/kernel_v2/config/disk_test.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/unit/plugins/kernel_v2/config/disk_test.rb b/test/unit/plugins/kernel_v2/config/disk_test.rb
index b05d4f105fb..05e91ced6ed 100644
--- a/test/unit/plugins/kernel_v2/config/disk_test.rb
+++ b/test/unit/plugins/kernel_v2/config/disk_test.rb
@@ -119,7 +119,7 @@ def assert_valid
   describe "#add_provider_config" do
     it "normalizes provider config" do
       test_provider_config = {provider__something: "special" }
-      subject.add_provider_config(test_provider_config)
+      subject.add_provider_config(**test_provider_config)
       expect(subject.provider_config).to eq( { provider: {something: "special" }} )
     end
   end
From bda7c07c02fafb2a3817982d827fc12d71daa817 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Fri, 7 May 2021 01:49:31 +0200
Subject: [PATCH] Remove unsused &block in add_provider_config.

Also AFAIK this is not valid with Ruby 3.0.
---
 plugins/kernel_v2/config/disk.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb
index 0062d8d354b..bd16941ff3c 100644
--- a/plugins/kernel_v2/config/disk.rb
+++ b/plugins/kernel_v2/config/disk.rb
@@ -85,7 +85,7 @@ def initialize(type)
       # Duplicates will be overriden
       #
       # @param [Hash] options
-      def add_provider_config(**options, &block)
+      def add_provider_config(**options)
         current = {}
         options.each do |k,v|
           opts = k.to_s.split("__")
From 3ec791d1687903f6d7a7d837b27633559f791230 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20Caama=C3=B1o=20Ruiz?= <jcaamano@suse.com>
Date: Wed, 12 May 2021 17:01:34 +0200
Subject: [PATCH] Additional ruby 3.0 keyword argument fixes

---
 lib/vagrant/plugin/v2/trigger.rb         | 2 +-
 plugins/provisioners/container/client.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/vagrant/plugin/v2/trigger.rb b/lib/vagrant/plugin/v2/trigger.rb
index 99d6ac05325..731b5854733 100644
--- a/lib/vagrant/plugin/v2/trigger.rb
+++ b/lib/vagrant/plugin/v2/trigger.rb
@@ -271,7 +271,7 @@ def run(config, on_error, exit_codes)
                 options[:color] = :red if !config.keep_color
               end
 
-              @ui.detail(data, options)
+              @ui.detail(data, **options)
             end
             if !exit_codes.include?(result.exit_code)
               raise Errors::TriggersBadExitCodes,
diff --git a/plugins/provisioners/container/client.rb b/plugins/provisioners/container/client.rb
index 72a2d86ab44..db3e2c0ac94 100644
--- a/plugins/provisioners/container/client.rb
+++ b/plugins/provisioners/container/client.rb
@@ -195,7 +195,7 @@ def handle_comm(type, data)
           options = {}
           #options[:color] = color if !config.keep_color
 
-          @machine.ui.info(data.chomp, options)
+          @machine.ui.info(data.chomp, **options)
         end
       end
     end