#28 Fix FTBFS for ruby 3.1
Merged 2 years ago by jackorp. Opened 2 years ago by jackorp.
rpms/ jackorp/vagrant rawhide  into  rawhide

@@ -0,0 +1,72 @@ 

+ From 2b1c25d247aba492e582a01cff8ecdd33d4d165b Mon Sep 17 00:00:00 2001

+ From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>

+ Date: Mon, 28 Feb 2022 10:46:17 +0100

+ Subject: [PATCH 1/2] Stop using the last argument as kwargs in unit tests

+ 

+ A few unit tests started failing with Ruby 3.0, because they were relying on

+ keyword arguments being converted into hashes automatically. This behavior was

+ deprecated in Ruby 2.7 and results in errors in Ruby 3.0 onward.

+ 

+ For further details:

+ https://rubyreferences.github.io/rubychanges/3.0.html#keyword-arguments-are-now-fully-separated-from-positional-arguments

+ ---

+  test/unit/plugins/commands/package/command_test.rb            | 4 ++--

+  .../plugins/providers/hyperv/action/read_guest_ip_test.rb     | 2 +-

+  test/unit/vagrant/ui_test.rb                                  | 4 ++--

+  3 files changed, 5 insertions(+), 5 deletions(-)

+ 

+ diff --git a/test/unit/plugins/commands/package/command_test.rb b/test/unit/plugins/commands/package/command_test.rb

+ index 7b289bd1e3a..d0f81393bf6 100644

+ --- a/test/unit/plugins/commands/package/command_test.rb

+ +++ b/test/unit/plugins/commands/package/command_test.rb

+ @@ -64,7 +64,7 @@

+  

+          it "packages default machine inside specified folder" do

+            expect(package_command).to receive(:package_vm).with(

+ -            a_machine_named('default'), :output => "package-output-folder/default"

+ +            a_machine_named('default'), { output: "package-output-folder/default" }

+            )

+            package_command.execute

+          end

+ @@ -96,7 +96,7 @@

+          let(:argv){ ['--base', 'machine-id'] }

+  

+          it "packages vm defined within virtualbox" do

+ -          expect(package_command).to receive(:package_base).with(:base => 'machine-id')

+ +          expect(package_command).to receive(:package_base).with({ base: 'machine-id' })

+            package_command.execute

+          end

+  

+ diff --git a/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb b/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb

+ index 5642c6271f1..ecce003a602 100644

+ --- a/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb

+ +++ b/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb

+ @@ -31,7 +31,7 @@

+      end

+  

+      it "should set the host information into the env" do

+ -      expect(env).to receive(:[]=).with(:machine_ssh_info, host: "ADDRESS")

+ +      expect(env).to receive(:[]=).with(:machine_ssh_info, { host: "ADDRESS" })

+        expect(driver).to receive(:read_guest_ip).and_return("ip" => "ADDRESS")

+        subject.call(env)

+      end

+ diff --git a/test/unit/vagrant/ui_test.rb b/test/unit/vagrant/ui_test.rb

+ index e484b81543b..120b1dda2a6 100644

+ --- a/test/unit/vagrant/ui_test.rb

+ +++ b/test/unit/vagrant/ui_test.rb

+ @@ -379,12 +379,12 @@

+  

+    describe "#machine" do

+      it "sets the target option" do

+ -      expect(ui).to receive(:machine).with(:foo, target: prefix)

+ +      expect(ui).to receive(:machine).with(:foo, { target: prefix })

+        subject.machine(:foo)

+      end

+  

+      it "preserves existing options" do

+ -      expect(ui).to receive(:machine).with(:foo, :bar, foo: :bar, target: prefix)

+ +      expect(ui).to receive(:machine).with(:foo, :bar, { foo: :bar, target: prefix })

+        subject.machine(:foo, :bar, foo: :bar)

+      end

+    end

+ 

file modified
+18 -1
@@ -7,7 +7,7 @@ 

  

  Name: vagrant

  Version: 2.2.19

- Release: 2%{?dist}

+ Release: 3%{?dist}

  Summary: Build and distribute virtualized development environments

  License: MIT

  URL: http://vagrantup.com
@@ -28,6 +28,9 @@ 

  # Do not load runtime dependencies in %%check if vagrant is not loaded

  # https://github.com/hashicorp/vagrant/pull/10945

  Patch1: vagrant-2.2.9-do-not-load-dependencies.patch

+ # Fix spec test suite for new rspec-mocks.

+ # https://github.com/hashicorp/vagrant/pull/12699

+ Patch2: vagrant-2.2.19-fix-3.1-compatibility.patch

  

  # The load directive is supported since RPM 4.12, i.e. F21+. The build process

  # fails on older Fedoras.
@@ -49,6 +52,7 @@ 

  Requires: rubygem(net-sftp) >= 2.1

  Requires: rubygem(rest-client) >= 1.6.0

  Requires: rubygem(rubyzip) >= 1.1.7

+ Requires: rubygem(net-ftp)

  Requires: bsdtar

  Requires: curl

  
@@ -84,6 +88,8 @@ 

  BuildRequires: rubygem(webmock)

  BuildRequires: rubygem(webrick)

  BuildRequires: rubygem(fake_ftp)

+ BuildRequires: rubygem(rake)

+ BuildRequires: rubygem(net-ftp)

  BuildRequires: pkgconfig(bash-completion)

  %if %{with help2man}

  BuildRequires: help2man
@@ -117,6 +123,7 @@ 

  %setup -q -b2

  

  %patch0 -p1

+ %patch2 -p1

  

  # TODO: package vagrant_cloud, as it is not in Fedora yet

  %gemspec_remove_dep -s %{name}.gemspec -g vagrant_cloud
@@ -127,6 +134,11 @@ 

  sed -i '/^\s*I18n\..*$/ s/^/#/g' plugins/commands/login/plugin.rb

  sed -i '/^\s*command(:login) do$/,/\s*end$/ s/^/#/g' plugins/commands/login/plugin.rb

  

+ # Expand required Ruby compatibility, otherwise RubyGems throws exceptions.

+ # Relevant rhbz: https://bugzilla.redhat.com/show_bug.cgi?id=2053476#c0

+ # Relevant RubyGems issue: https://github.com/rubygems/rubygems/issues/4338

+ sed -i -e '/required_ruby_version/ s/, "< 3.1"//' %{name}.gemspec

+ 

  # We have older version in Fedora

  %gemspec_remove_dep -s %{name}.gemspec -g net-sftp '~> 3.0'

  %gemspec_add_dep -s %{name}.gemspec -g net-sftp '>= 2.1.2'
@@ -487,6 +499,11 @@ 

  %{vagrant_plugin_instdir}/vagrant-spec.config.example.rb

  

  %changelog

+ * Mon Feb 21 2022 Jarek Prokop <jprokop@redhat.com> - 2.2.19-3

+ - Fix FTBFS due to new rspec-mocks.

+ - Relax required ruby version.

+   Resolves: rhbz#2053476

+ 

  * Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org>

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

  

@pvalena PTAL

Fixes FTBFS, but it does not fix the runtime.

Does if fix Ruby compatibility or rspec-mocks compatibility

This PR fixes rspec-mocks compatibility. I am still investigating Ruby compatibility (I'll share my findings under bz bug [0]).

Do you have any relevant upstream PR?

That is TBD, I want to test how it builds with upstream's rspec-mocks first (and with uncommented test cases).

[0] https://bugzilla.redhat.com/show_bug.cgi?id=2053476#c2

Let's build this in my vagrant-testing COPR :)

rebased onto d7023daefe58f4c56680964ac4a6beb356d5b1e3

2 years ago

I have added a commit relaxing the required Ruby version. This is a known issue on rubygem: https://github.com/rubygems/rubygems/issues/4338 -- a bit different process but the symptoms are identical as per comment on https://github.com/rubygems/rubygems/issues/5380#issuecomment-1057186826

This change is built in the vagrant-testing copr: https://download.copr.fedorainfracloud.org/results/pvalena/vagrant-testing/fedora-rawhide-x86_64/03590402-vagrant/

Though I set the release a bump too high (2.1) on that build.

Vagrant now at least does not fail on Rubygems' dependency resolution.

Shouldn't this refer to rhbz#2053476 ?

Any upstream ticket or reference to the source of this patch?

Generally LGTM and I think we should build this, just to unblock Vagrant build. But please address the two comments above.

rebased onto 5dda892770612ef4fdb58fd73ce7d5daaaf3c3d9

2 years ago

rebased onto 1b595958d61cc33c6cd5cdf271b6d2a855fb6d2b

2 years ago

rebased onto f8a97e7

2 years ago

I have addressed the comments in the recent rebases. I'll do some local testing that it works as expected then merge and build.

Pull-Request has been merged by jackorp

2 years ago