Bug 1835836 - rubygem-psych: `<class:Parser>': superclass mismatch for class Mark (TypeError)
Summary: rubygem-psych: `<class:Parser>': superclass mismatch for class Mark (TypeError)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ruby
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Vít Ondruch
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1850448 1851521 (view as bug list)
Depends On: 1845530
Blocks: 1836201 1842989
TreeView+ depends on / blocked
 
Reported: 2020-05-14 15:01 UTC by Jun Aruga
Modified: 2020-07-02 01:13 UTC (History)
12 users (show)

Fixed In Version: ruby-2.7.1-132.fc33 ruby-2.7.1-132.fc32
Clone Of:
: 1836201 (view as bug list)
Environment:
Last Closed: 2020-07-02 01:13:10 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jun Aruga 2020-05-14 15:01:53 UTC
Description of problem:

When rubygem-psych RPM is installed, run the following test.rb script. Then the following error happens.

```
$ gem info psych

*** LOCAL GEMS ***

psych (3.1.0)
    Authors: Aaron Patterson, SHIBATA Hiroshi, Charles Oliver Nutter
    Homepage: https://github.com/ruby/psych
    License: MIT
    Installed at: /usr/share/gems

    Psych is a YAML parser and emitter
```

```
$ cat test.rb 
require 'psych'
Gem.load_yaml
```

```
$ ruby test.rb
/usr/lib64/gems/ruby/psych-3.1.0/psych.so: warning: already initialized constant Psych::Parser::ANY
...

/usr/share/gems/gems/psych-3.1.0/lib/psych/parser.rb:34:in `<class:Parser>': superclass mismatch for class Mark (TypeError)
```


Version-Release number of selected component (if applicable):
ruby-2.7.1-130.fc33.x86_64
rubygem-psych-3.1.0-130.fc33.x86_64

How reproducible:


Steps to Reproduce:
1. Create this Ruby script.

```
$ cat test.rb 
require 'psych'
Gem.load_yaml
```

2. Run the script.

$ ruby test.rb 

Actual results:

```
$ ruby test.rb 
/usr/lib64/gems/ruby/psych-3.1.0/psych.so: warning: already initialized constant Psych::Parser::ANY
/usr/lib64/gems/ruby/psych-3.1.0/psych.so: warning: already initialized constant Psych::Parser::UTF8
/usr/lib64/gems/ruby/psych-3.1.0/psych.so: warning: already initialized constant Psych::Parser::UTF16LE
/usr/lib64/gems/ruby/psych-3.1.0/psych.so: warning: already initialized constant Psych::Parser::UTF16BE
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:7: warning: already initialized constant Psych::ClassLoader::BIG_DECIMAL
/usr/share/ruby/psych/class_loader.rb:7: warning: previous definition of BIG_DECIMAL was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:8: warning: already initialized constant Psych::ClassLoader::COMPLEX
/usr/share/ruby/psych/class_loader.rb:8: warning: previous definition of COMPLEX was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:9: warning: already initialized constant Psych::ClassLoader::DATE
/usr/share/ruby/psych/class_loader.rb:9: warning: previous definition of DATE was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:10: warning: already initialized constant Psych::ClassLoader::DATE_TIME
/usr/share/ruby/psych/class_loader.rb:10: warning: previous definition of DATE_TIME was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:11: warning: already initialized constant Psych::ClassLoader::EXCEPTION
/usr/share/ruby/psych/class_loader.rb:11: warning: previous definition of EXCEPTION was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:12: warning: already initialized constant Psych::ClassLoader::OBJECT
/usr/share/ruby/psych/class_loader.rb:12: warning: previous definition of OBJECT was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:13: warning: already initialized constant Psych::ClassLoader::PSYCH_OMAP
/usr/share/ruby/psych/class_loader.rb:13: warning: previous definition of PSYCH_OMAP was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:14: warning: already initialized constant Psych::ClassLoader::PSYCH_SET
/usr/share/ruby/psych/class_loader.rb:14: warning: previous definition of PSYCH_SET was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:15: warning: already initialized constant Psych::ClassLoader::RANGE
/usr/share/ruby/psych/class_loader.rb:15: warning: previous definition of RANGE was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:16: warning: already initialized constant Psych::ClassLoader::RATIONAL
/usr/share/ruby/psych/class_loader.rb:16: warning: previous definition of RATIONAL was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:17: warning: already initialized constant Psych::ClassLoader::REGEXP
/usr/share/ruby/psych/class_loader.rb:17: warning: previous definition of REGEXP was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:18: warning: already initialized constant Psych::ClassLoader::STRUCT
/usr/share/ruby/psych/class_loader.rb:18: warning: previous definition of STRUCT was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:19: warning: already initialized constant Psych::ClassLoader::SYMBOL
/usr/share/ruby/psych/class_loader.rb:19: warning: previous definition of SYMBOL was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/class_loader.rb:65: warning: already initialized constant Psych::ClassLoader::CACHE
/usr/share/ruby/psych/class_loader.rb:65: warning: previous definition of CACHE was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:9: warning: already initialized constant Psych::ScalarScanner::TIME
/usr/share/ruby/psych/scalar_scanner.rb:9: warning: previous definition of TIME was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:12: warning: already initialized constant Psych::ScalarScanner::FLOAT
/usr/share/ruby/psych/scalar_scanner.rb:12: warning: previous definition of FLOAT was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:17: warning: already initialized constant Psych::ScalarScanner::INTEGER
/usr/share/ruby/psych/scalar_scanner.rb:17: warning: previous definition of INTEGER was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/stream.rb:13: warning: already initialized constant Psych::Nodes::Stream::ANY
/usr/share/ruby/psych/nodes/stream.rb:13: warning: previous definition of ANY was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/stream.rb:16: warning: already initialized constant Psych::Nodes::Stream::UTF8
/usr/share/ruby/psych/nodes/stream.rb:16: warning: previous definition of UTF8 was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/stream.rb:19: warning: already initialized constant Psych::Nodes::Stream::UTF16LE
/usr/share/ruby/psych/nodes/stream.rb:19: warning: previous definition of UTF16LE was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/stream.rb:22: warning: already initialized constant Psych::Nodes::Stream::UTF16BE
/usr/share/ruby/psych/nodes/stream.rb:22: warning: previous definition of UTF16BE was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:43: warning: already initialized constant Psych::Nodes::Sequence::ANY
/usr/share/ruby/psych/nodes/sequence.rb:43: warning: previous definition of ANY was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:46: warning: already initialized constant Psych::Nodes::Sequence::BLOCK
/usr/share/ruby/psych/nodes/sequence.rb:46: warning: previous definition of BLOCK was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/sequence.rb:49: warning: already initialized constant Psych::Nodes::Sequence::FLOW
/usr/share/ruby/psych/nodes/sequence.rb:49: warning: previous definition of FLOW was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:10: warning: already initialized constant Psych::Nodes::Scalar::ANY
/usr/share/ruby/psych/nodes/scalar.rb:10: warning: previous definition of ANY was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:13: warning: already initialized constant Psych::Nodes::Scalar::PLAIN
/usr/share/ruby/psych/nodes/scalar.rb:13: warning: previous definition of PLAIN was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:16: warning: already initialized constant Psych::Nodes::Scalar::SINGLE_QUOTED
/usr/share/ruby/psych/nodes/scalar.rb:16: warning: previous definition of SINGLE_QUOTED was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:19: warning: already initialized constant Psych::Nodes::Scalar::DOUBLE_QUOTED
/usr/share/ruby/psych/nodes/scalar.rb:19: warning: previous definition of DOUBLE_QUOTED was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:22: warning: already initialized constant Psych::Nodes::Scalar::LITERAL
/usr/share/ruby/psych/nodes/scalar.rb:22: warning: previous definition of LITERAL was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/scalar.rb:25: warning: already initialized constant Psych::Nodes::Scalar::FOLDED
/usr/share/ruby/psych/nodes/scalar.rb:25: warning: previous definition of FOLDED was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:17: warning: already initialized constant Psych::Nodes::Mapping::ANY
/usr/share/ruby/psych/nodes/mapping.rb:17: warning: previous definition of ANY was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:20: warning: already initialized constant Psych::Nodes::Mapping::BLOCK
/usr/share/ruby/psych/nodes/mapping.rb:20: warning: previous definition of BLOCK was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/mapping.rb:23: warning: already initialized constant Psych::Nodes::Mapping::FLOW
/usr/share/ruby/psych/nodes/mapping.rb:23: warning: previous definition of FLOW was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/visitors/visitor.rb:11: warning: already initialized constant Psych::Visitors::Visitor::DISPATCH
/usr/share/ruby/psych/visitors/visitor.rb:11: warning: previous definition of DISPATCH was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/visitors/to_ruby.rb:336: warning: already initialized constant Psych::Visitors::ToRuby::SHOVEL
/usr/share/ruby/psych/visitors/to_ruby.rb:336: warning: previous definition of SHOVEL was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/handler.rb:27: warning: already initialized constant Psych::Handler::OPTIONS
/usr/share/ruby/psych/handler.rb:27: warning: previous definition of OPTIONS was here
/usr/share/gems/gems/psych-3.1.0/lib/psych/handler.rb:30: warning: already initialized constant Psych::Handler::EVENTS
/usr/share/ruby/psych/handler.rb:30: warning: previous definition of EVENTS was here
Traceback (most recent call last):
	9: from test.rb:2:in `<main>'
	8: from /usr/share/rubygems/rubygems.rb:696:in `load_yaml'
	7: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:72:in `require'
	6: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:72:in `require'
	5: from /usr/share/gems/gems/psych-3.1.0/lib/psych.rb:20:in `<top (required)>'
	4: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:72:in `require'
	3: from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:72:in `require'
	2: from /usr/share/gems/gems/psych-3.1.0/lib/psych/parser.rb:2:in `<top (required)>'
	1: from /usr/share/gems/gems/psych-3.1.0/lib/psych/parser.rb:33:in `<module:Psych>'
/usr/share/gems/gems/psych-3.1.0/lib/psych/parser.rb:34:in `<class:Parser>': superclass mismatch for class Mark (TypeError)
```


Expected results:

The error does not happens. This issue does not happen on the upstream Ruby.

```
$ ruby test.rb 
$ echo $?
0
```

Additional info:

I think this issue is related to this upstream issue.
https://github.com/ruby/psych/issues/386

Comment 1 Jun Aruga 2020-05-14 17:37:07 UTC
This issue also happen on f31 with:
  ruby-2.7.1-130.fc32.x86_64
  rubygems-3.1.2-130.fc32.noarch
  rubygem-psych-3.1.0-130.fc32.x86_64.
But it does not happen on f30 with:
  ruby-2.6.5-124.fc31.x86_64
  rubygems-3.0.3-124.fc31.noarch
  rubygem-psych-3.1.0-124.fc31.x86_64.

On f31, the result of `ruby test.rb` is like this.

```
$ ruby test.rb 
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:237: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:237: warning: previous definition of LIBYAML_VERSION was here
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:239: warning: already initialized constant Psych::NOT_GIVEN
/usr/share/ruby/psych.rb:239: warning: previous definition of NOT_GIVEN was here

$ echo $?
0
```

Comment 2 Jun Aruga 2020-05-14 18:21:48 UTC
Sorry for the 2 typos.

> This issue also happen on f31 with:

Correction
This issue also happen on f32 with:

> But it does not happen on f30 with:

Correction
But it does not happen on f31 with:

Comment 3 Vít Ondruch 2020-05-14 20:52:39 UTC
> On f31, the result of `ruby test.rb` is like this.
> 
> ```
> $ ruby test.rb 
> /usr/share/gems/gems/psych-3.1.0/lib/psych.rb:237: warning: already
> initialized constant Psych::LIBYAML_VERSION
> /usr/share/ruby/psych.rb:237: warning: previous definition of
> LIBYAML_VERSION was here
> /usr/share/gems/gems/psych-3.1.0/lib/psych.rb:239: warning: already
> initialized constant Psych::NOT_GIVEN
> /usr/share/ruby/psych.rb:239: warning: previous definition of NOT_GIVEN was
> here
> 
> $ echo $?
> 0
> ```

IOW the issues is still the same, only the magnitude is different.

https://github.com/rubygems/rubygems/issues/3131

Comment 4 Mamoru TASAKA 2020-05-14 23:51:14 UTC
This is the same as https://src.fedoraproject.org/rpms/rubygem-racc/pull-request/1#comment-37003

i.e.
```
require "psych"
gem "psych"
require "psych"
```

causes this error.

Comment 5 Jun Aruga 2020-05-15 08:53:49 UTC
Thanks for the information. It's very helpful.

I found a temporary workflow to avoid this issue.

```
<mock-chroot> sh-5.0# diff -u /usr/share/rubygems/rubygems.rb{.orig,}
--- /usr/share/rubygems/rubygems.rb.orig	2020-03-31 12:44:55.000000000 +0200
+++ /usr/share/rubygems/rubygems.rb	2020-05-15 10:48:33.008250387 +0200
@@ -685,7 +685,7 @@
     return unless defined?(gem)
 
     begin
-      gem 'psych', '>= 2.0.0'
+      # gem 'psych', '>= 2.0.0'
     rescue Gem::LoadError
       # It's OK if the user does not have the psych gem installed.  We will
       # attempt to require the stdlib version
```

Then the above test.rb works.

```
$ ruby test.rb 

$ echo $?
0
```

As a long term solution in Fedora, I think that it's better to change rubygem-psych to the default bundled gem like rubygem-racc did.

Comment 6 Vít Ondruch 2020-05-15 08:58:48 UTC
As a long term, RubyGems should not call `gem` command. There used to be the Syck/Psych switch, which was partly removed, but not entirely. I was looking into this a bit, but it is unfortunately rabbit hole.

Comment 7 Jun Aruga 2020-05-15 09:47:04 UTC
> I found a temporary workflow to avoid this issue.

Or like this in safer manner.

```
<mock-chroot> sh-5.0# diff -u /usr/share/rubygems/rubygems.rb{.orig,}
--- /usr/share/rubygems/rubygems.rb.orig	2020-03-31 12:44:55.000000000 +0200
+++ /usr/share/rubygems/rubygems.rb	2020-05-15 11:43:34.851595500 +0200
@@ -685,7 +685,11 @@
     return unless defined?(gem)
 
     begin
-      gem 'psych', '>= 2.0.0'
+      begin
+        require 'psych'
+      rescue ::LoadError
+        gem 'psych', '>= 2.0.0'
+      end
     rescue Gem::LoadError
       # It's OK if the user does not have the psych gem installed.  We will
       # attempt to require the stdlib version
```

Comment 8 Jun Aruga 2020-05-15 10:53:55 UTC
Here is a list of the rubygem packages depending on psych.
When loading the rubygem package and calling Gem.load_yaml, this issue happen.
https://rubygems.org/gems/psych/reverse_dependencies

Rubocop had had the issue. But the project dropped the psych dependency later to avoid the issue.
https://github.com/rubocop-hq/rubocop/commit/95d2110e49e160ffb785a74b22727593f17d552b

Comment 9 Vít Ondruch 2020-05-15 13:53:11 UTC
(In reply to Jun Aruga from comment #7)
First and foremost, RubyGems should not ever call `gem 'psych'`, especially not without checking if Psych or Psych::VERSION constant already exists.

Comment 10 Jun Aruga 2020-05-15 15:21:39 UTC
> First and foremost, RubyGems should not ever call `gem 'psych'`, especially not without checking if Psych or Psych::VERSION constant already exists.

Sure. I reported the issue to the upstream with the suggestion here.
https://github.com/rubygems/rubygems/issues/3629

Comment 11 Jun Aruga 2020-05-19 08:01:46 UTC
Here is the upstream patch to fix this issue, that was merged in the upstream a few hours ago.

Remove explicit `psych` activation
https://github.com/rubygems/rubygems/commit/1ccf0912a161d20e0c4a7b139fd76e8739a411ba

Just applying the patch fixes the issue. Shall we apply this patch in ruby.spec?

But as this issue originally came from the non-default gem psych in Fedora Ruby, shall we change psych to the default gem like racc and did_you_mean in Ruby RPM?

See https://github.com/rubygems/rubygems/issues/3629#issuecomment-630304511 for detail.

> Unfortunately, rubygems auto-activation feature relies on either early detecting that a default gem is being required, or rescuing the LoadError produced by the standard require otherwise in order to try to discover the file on GEM_PATH entries.
>
> So there's not much we can do here, my recommendation is that you ship a default specification for the default psych and remove the "regular" gem.

Comment 12 Vít Ondruch 2020-05-19 08:32:33 UTC
(In reply to Jun Aruga from comment #11)
> Here is the upstream patch to fix this issue, that was merged in the
> upstream a few hours ago.
> 
> Remove explicit `psych` activation
> https://github.com/rubygems/rubygems/commit/
> 1ccf0912a161d20e0c4a7b139fd76e8739a411ba
> 

Nice, thx.

> Just applying the patch fixes the issue. Shall we apply this patch in
> ruby.spec?

I think it would be more useful if you ensured Ruby upstream backports this patch into Ruby. I don't see too much pressure to apply the patch ATM.
 
> But as this issue originally came from the non-default gem psych in Fedora
> Ruby, shall we change psych to the default gem like racc and did_you_mean in
> Ruby RPM?

This is WIP. But unfortunately the transition will be probably painful for Psych due to symlink <-> directory conversions.

Comment 13 Jun Aruga 2020-05-20 14:15:36 UTC
> Remove explicit `psych` activation
> https://github.com/rubygems/rubygems/commit/1ccf0912a161d20e0c4a7b139fd76e8739a411ba

One more upstream patch for the same kind of issue. The trigger point is different.

bundler: Remove explicit `psych` activation.
https://github.com/rubygems/rubygems/commit/5ff18cd7528286de5257c0b3af12ecbcfe9256a5

> I think it would be more useful if you ensured Ruby upstream backports this patch into Ruby. I don't see too much pressure to apply the patch ATM.

Okay. Here is the ticket I opened now.
https://bugs.ruby-lang.org/issues/16904

> This is WIP. But unfortunately the transition will be probably painful for Psych due to symlink <-> directory conversions.

Okay. Thanks for that.

Comment 14 Jun Aruga 2020-05-26 11:55:48 UTC
> Okay. Here is the ticket I opened now.
> https://bugs.ruby-lang.org/issues/16904

According to the upstream tickets, it has not been fixed on Ruby. But there are some possible patches to fix the issue. If you like the issue will be fixed on Fedora Ruby before Ruby 2.7 will apply it, I wish you tell us which patch you would like to be applied to Fedora Ruby.

I still think the following patch is the most proper patch in this case, because it is simple, and easy to apply. There are relatively a smaller risk about breaking the Fedora Ruby.
https://github.com/rubygems/rubygems/commit/1ccf0912a161d20e0c4a7b139fd76e8739a411ba

Comment 15 Garrett Hyde 2020-05-27 17:08:01 UTC
(In reply to Jun Aruga from comment #7)
> > I found a temporary workflow to avoid this issue.
> 
> Or like this in safer manner.
> 
> ```
> <mock-chroot> sh-5.0# diff -u /usr/share/rubygems/rubygems.rb{.orig,}
> --- /usr/share/rubygems/rubygems.rb.orig	2020-03-31 12:44:55.000000000 +0200
> +++ /usr/share/rubygems/rubygems.rb	2020-05-15 11:43:34.851595500 +0200
> @@ -685,7 +685,11 @@
>      return unless defined?(gem)
>  
>      begin
> -      gem 'psych', '>= 2.0.0'
> +      begin
> +        require 'psych'
> +      rescue ::LoadError
> +        gem 'psych', '>= 2.0.0'
> +      end
>      rescue Gem::LoadError
>        # It's OK if the user does not have the psych gem installed.  We will
>        # attempt to require the stdlib version
> ```

This bug also impacts the vagrant package (2.2.9-1). When you execute `vagrant plugin install ...`, the same "superclass mismatch for class Mark (TypeError)" error is thrown. After applying Jun Aruga's patch (see above), `vagrant plugin install ...` works.

Comment 16 Vít Ondruch 2020-05-28 11:11:43 UTC
(In reply to Jun Aruga from comment #14)
> > Okay. Here is the ticket I opened now.
> > https://bugs.ruby-lang.org/issues/16904
> 
> According to the upstream tickets, it has not been fixed on Ruby. But there
> are some possible patches to fix the issue. If you like the issue will be
> fixed on Fedora Ruby before Ruby 2.7 will apply it, I wish you tell us which
> patch you would like to be applied to Fedora Ruby.

This is the right fix IMO:

https://github.com/rubygems/rubygems/pull/3639

and especially this should be the critical piece:

https://github.com/rubygems/rubygems/pull/3639/commits/22ad5717c38feda2375b53628d15ae3db2195684

If this PR is applied, then the call to the `gem "psych"` should pass just fine.

> I still think the following patch is the most proper patch in this case,
> because it is simple, and easy to apply. There are relatively a smaller risk
> about breaking the Fedora Ruby.
> https://github.com/rubygems/rubygems/commit/
> 1ccf0912a161d20e0c4a7b139fd76e8739a411ba

I am still not convinced this patch is good enough, because it removes the Psych version guard. I think that Ruby can be fooled to load older version of Psych before the RubyGems requires it and this would lead to RubyGems crash. But one would need to put some effort into it, so chances this will cause issues are quite small. If I'll get bored one day, I'll try to put together some reproducer. But this is OT in this ticket.

Comment 17 Vít Ondruch 2020-05-28 12:52:26 UTC
I have opened this [1] PR (build is here [2]), which should include the changes from [3] and top of several other PRs, which allows it to apply cleanly and all of the touches the same part of code.

Testing with Vagrant, the plugin installation works and it allows to remove the following workaround [4], however there are still two warnings:

~~~
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:233: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:233: warning: previous definition of LIBYAML_VERSION was here
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:235: warning: already initialized constant Psych::NOT_GIVEN
/usr/share/ruby/psych.rb:235: warning: previous definition of NOT_GIVEN was here
~~~

I have also tried to add content of [5], but it did not help. Anyway, Vagrant is a bit special, so where else this was issue? I can't remember any package from top of my head :/


[1]: https://src.fedoraproject.org/rpms/rubygems/pull-request/3
[2]: http://koji.fedoraproject.org/koji/taskinfo?taskID=45099038
[3]: https://github.com/rubygems/rubygems/pull/3639
[4]: https://src.fedoraproject.org/rpms/vagrant/blob/master/f/vagrant.spec#_288
[5]: https://github.com/rubygems/rubygems/pull/3429

Comment 18 Jun Aruga 2020-06-02 12:00:24 UTC
> I have also tried to add content of [5], but it did not help. Anyway, Vagrant is a bit special, so where else this was issue? I can't remember any package from top of my head :/

Thanks for the work.
Possibly rubocop < 0.68 has the issue, according to the following patch.
> https://github.com/rubocop-hq/rubocop/commit/95d2110e49e160ffb785a74b22727593f17d552b

And you can pick up the possible gem from the list.
https://rubygems.org/gems/psych/reverse_dependencies

Comment 19 Jun Aruga 2020-06-05 13:52:47 UTC
Related to comment on the PR [1] , I tested the following script `test.rb` with the new rubygems (`rubygems-3.1.3-201.fc33`) by the PR [1].
The `test.rb`'s `test_gems` are the gems that is a default gem in Upstream Ruby, but not in Fedora Ruby.
And the result does not show the error, showing some warnings in case of irb and psych.

```
$ cat test.rb 
test_gems = [
  'irb',
  'rdoc',
  'bigdecimal',
  ['io/console', 'io-console'],
  'json',
  'openssl',
  'psych',
  'bundler'
]
test_gems.each do |a_gem|
  a_gem_req = a_gem
  a_gem_gem = a_gem
  if a_gem.class == Array
    a_gem_req = a_gem[0]
    a_gem_gem = a_gem[1]
  end
  puts "== gem: #{a_gem_gem} =="
  require a_gem_req
  gem a_gem_gem
  require a_gem_req
end
```

```
$ rpm -q ruby
warning: Found bdb Packages database while attempting sqlite backend: using bdb backend.
ruby-2.7.1-131.fc33.x86_64

$ rpm -q rubygems
warning: Found bdb Packages database while attempting sqlite backend: using bdb backend.
rubygems-3.1.3-201.fc33.noarch

$ ruby test.rb
== gem: irb ==
/usr/share/ruby/irb/input-method.rb:18: warning: already initialized constant IRB::STDIN_FILE_
NAME
/usr/share/gems/gems/irb-1.2.3/lib/irb/input-method.rb:18: warning: previous definition of STDIN_FILE_NAME was here
== gem: rdoc ==
== gem: bigdecimal ==
== gem: io-console ==
== gem: json ==
== gem: openssl ==
== gem: psych ==
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:233: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:233: warning: previous definition of LIBYAML_VERSION was here
/usr/share/gems/gems/psych-3.1.0/lib/psych.rb:235: warning: already initialized constant Psych::NOT_GIVEN
/usr/share/ruby/psych.rb:235: warning: previous definition of NOT_GIVEN was here
== gem: bundler ==

$ echo $?
0
```

[1] https://src.fedoraproject.org/rpms/rubygems/pull-request/3#comment-46056

Comment 20 Jun Aruga 2020-06-24 10:01:25 UTC
The patch to fix this issue was applied to rpms/rubygems. It's time to apply it to rpms/ruby.
https://src.fedoraproject.org/rpms/rubygems/c/634b956b770aad8ec6acadec151e94893cac89b7?branch=master

Comment 21 Vít Ondruch 2020-06-24 11:42:52 UTC
*** Bug 1850448 has been marked as a duplicate of this bug. ***

Comment 22 Fedora Update System 2020-06-26 14:08:04 UTC
FEDORA-2020-b2cf8f17da has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-b2cf8f17da

Comment 23 Fedora Update System 2020-06-27 03:12:51 UTC
FEDORA-2020-b2cf8f17da has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-b2cf8f17da`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-b2cf8f17da

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 24 Vít Ondruch 2020-06-29 12:29:44 UTC
*** Bug 1851521 has been marked as a duplicate of this bug. ***

Comment 25 Fedora Update System 2020-07-02 01:13:10 UTC
FEDORA-2020-b2cf8f17da has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.