Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903891 - dev-ruby/rb-inotify-0.10.1 fails to install with error: undefined method `_native_parse' for #<Psych::Parser:0x0000562e0f1b01f0> (NoMethodError)
Summary: dev-ruby/rb-inotify-0.10.1 fails to install with error: undefined method `_na...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Ruby Team
URL: https://github.com/ruby/psych/discuss...
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2023-04-06 00:36 UTC by Sebastian Pipping
Modified: 2024-06-24 19:40 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Build log (dev-ruby:rb-inotify-0.10.1:20230405-213459.log,3.57 KB, text/x-log)
2023-04-06 00:37 UTC, Sebastian Pipping
Details
Build log (dev-ruby:rb-inotify-0.10.1:20230412-175533.log,3.65 KB, text/x-log)
2023-04-12 18:08 UTC, Sebastian Pipping
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Pipping gentoo-dev 2023-04-06 00:36:44 UTC
The error is this:

>>> Install dev-ruby/rb-inotify-0.10.1 into /var/tmp/portage/dev-ruby/rb-inotify-0.10.1/image
 * Running install phase for ruby27
Traceback (most recent call last):
        6: from -e:1:in `<main>'
        5: from /usr/lib64/ruby/site_ruby/2.7.0/rubygems/specification.rb:1096:in `from_yaml'
        4: from /usr/lib64/ruby/site_ruby/2.7.0/rubygems/safe_yaml.rb:30:in `safe_load'
        3: from /usr/lib64/ruby/gems/2.7.0/gems/psych-5.1.0/lib/psych.rb:323:in `safe_load'
        2: from /usr/lib64/ruby/gems/2.7.0/gems/psych-5.1.0/lib/psych.rb:399:in `parse'
        1: from /usr/lib64/ruby/gems/2.7.0/gems/psych-5.1.0/lib/psych.rb:455:in `parse_stream'
/usr/lib64/ruby/gems/2.7.0/gems/psych-5.1.0/lib/psych/parser.rb:62:in `parse': undefined method `_native_parse' for #<Psych::Parser:0x0000562e0f1b01f0> (NoMethodError)

Attaching the build log in a second...
Comment 1 Sebastian Pipping gentoo-dev 2023-04-06 00:37:29 UTC
Created attachment 859592 [details]
Build log
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-06 00:41:40 UTC
What version of dev-ruby/safe_yaml is installed?
Comment 3 Sebastian Pipping gentoo-dev 2023-04-06 00:42:18 UTC
PS: This is without dev-ruby/safe_yaml installed.  For proof:

  # qfile /usr/lib64/ruby/site_ruby/2.7.0/rubygems/safe_yaml.rb
  dev-ruby/rubygems: /usr/lib64/ruby/site_ruby/2.7.0/rubygems/safe_yaml.rb
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-06 00:44:32 UTC
(In reply to Sebastian Pipping from comment #3)
> PS: This is without dev-ruby/safe_yaml installed.  For proof:
> 
>   # qfile /usr/lib64/ruby/site_ruby/2.7.0/rubygems/safe_yaml.rb
>   dev-ruby/rubygems: /usr/lib64/ruby/site_ruby/2.7.0/rubygems/safe_yaml.rb

Can you try install it (>=1.0.5-r2)? I think it'll override the bundled one with Ruby 2.7 and fix your issue.

For ruby2.7, we should probably make psych at least depend on that safe_yaml. 

Not that any of this matters that much anyway, as ruby27 is rapidly heading for the bin.
Comment 5 Sebastian Pipping gentoo-dev 2023-04-06 00:48:50 UTC
(In reply to Sam James from comment #4)
> Can you try install it (>=1.0.5-r2)?

Tried just now, installing dev-ruby/safe_yaml-1.0.5-r2 fails with the very same "undefined method" error.
Comment 6 Sebastian Pipping gentoo-dev 2023-04-12 18:08:24 UTC
Created attachment 859953 [details]
Build log

I just learned that Ruby 3.0.0 is affected also, this is not a 2.7-only problem.
Comment 7 Sebastian Pipping gentoo-dev 2023-04-12 19:22:21 UTC
What allowed be to install dev-ruby/rb-inotify successfully now is this
*workaround*:

  mv /usr/lib64/ruby/gems/3.0.0/gems/psych-5.1.0{,_RENAMED}
  mv /usr/lib64/ruby/gems/3.1.0/gems/psych-5.1.0{,_RENAMED}
  
(This assumes that one has =dev-ruby/psych-5.1.0 installed with
"ruby30 ruby31 ruby32 -ruby27", else it may need one more rename for 2.7.)

What the workaround does is it makes Ruby use its own copy of Psych
rather than the gem's one.  I believe that means that Ruby has trouble
loading the correct psych.so when the Gem is installed.

PS: Symbol "_native_parse" was first introduced…
- with Ruby 3_2_0_preview3 at
  https://github.com/ruby/ruby/commit/26135312f61014967ef223dd16ad6577ebd9c5d8
- with Psych 5.0.0 at
  https://github.com/ruby/psych/commit/bca7d2c54942205e9364f8b0c0a1948fd1442ec8
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-13 03:19:31 UTC
I wish I could reproduce this. I think it's possible that it needs special care when unbundling or similar, but I don't know yet.

If you do have some time, I'd appreciate it if you could find some instructions to run from a clean stage 3 to make it happen, but no obligation.
Comment 9 Sebastian Pipping gentoo-dev 2023-04-13 16:32:50 UTC
(In reply to Sam James from comment #8)
> I wish I could reproduce this.

I'm still playing with a reproducer, but I believe it may take nothing but:

  1. Ruby 2.7, 3.0 or 3.1 (but not 3.2)
  2. >=dev-ruby/psych-5 installed
  3. ruby32 -e $'require "psych"\nPsych.parse("---")'  # fine
  4. ruby30 -e $'require "psych"\nPsych.parse("---")'  # crashes


> If you do have some time, I'd appreciate it if you could find some
> instructions to run from a clean stage 3 to make it happen, but no
> obligation.

With some luck, I'll have a Dockerfile to reproduce with latest gentoo/stage3 soon, let's see.
Comment 10 Sebastian Pipping gentoo-dev 2023-04-13 23:32:35 UTC
(In reply to Sebastian Pipping from comment #9)
> With some luck, I'll have a Dockerfile to reproduce with latest
> gentoo/stage3 soon, let's see.

Turns out difficult.  Also, for some reason def-lang/ruby:3.0 brings /usr/lib64/ruby/gems/3.0.0/gems/psych-3.3.2 as well, giving this full picture:

  # ls -ad /usr/lib64/ruby/gems/*/gems/psych-*/ | xargs qfile
  dev-lang/ruby: /usr/lib64/ruby/gems/3.0.0/gems/psych-3.3.2
  dev-ruby/psych: /usr/lib64/ruby/gems/3.1.0/gems/psych-5.1.0
  dev-ruby/psych: /usr/lib64/ruby/gems/3.0.0/gems/psych-5.1.0

For anyone who likes to continue where I left off, my Dockerfile was this:

  FROM gentoo/stage3
  RUN emerge-webrsync
  RUN echo 'ACCEPT_KEYWORDS="amd64 ~amd64"' >> /etc/portage/make.conf
  RUN echo 'RUBY_TARGETS="ruby30 ruby31"' >> /etc/portage/make.conf
  RUN emerge -j2 -v --tree dev-ruby/psych
  RUN ls -ad /usr/lib64/ruby/gems/*/gems/psych-*/ | xargs qfile
  RUN ruby30 -e $'require "psych"\nPsych.parse("---")'
  RUN ruby31 -e $'require "psych"\nPsych.parse("---")'
Comment 11 Larry the Git Cow gentoo-dev 2024-06-24 19:40:55 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=460c97b79bf0962e9da7e11c6bbda13bd8c91ddb

commit 460c97b79bf0962e9da7e11c6bbda13bd8c91ddb
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-06-24 05:35:59 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-06-24 19:40:35 +0000

    profiles/base: mask dev-lang/ruby[static-libs]
    
    It breaks gem installation in mysterious ways and people keep
    tripping over it.
    
    graaff indicates on the PR that we'd like to remove it entirely for ruby:3.4
    given it'll bitrot if it's masked, but that this is a good option for now.
    
    Closes: https://bugs.gentoo.org/887223
    Closes: https://bugs.gentoo.org/891367
    Closes: https://bugs.gentoo.org/903891
    Closes: https://bugs.gentoo.org/917139
    Signed-off-by: Sam James <sam@gentoo.org>
    Closes: https://github.com/gentoo/gentoo/pull/37267
    Signed-off-by: Sam James <sam@gentoo.org>

 profiles/base/package.use.mask | 5 +++++
 1 file changed, 5 insertions(+)