appsignal-ruby: Compiling native extension fails when having `psych >= 5`

Timebox: 0.5 days

Describe the bug

After we’ve downgraded back to psych 4 compilation worked again.

To Reproduce

We are on ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [aarch64-linux-musl]

/app # gem install psych:5
/app # gem install appsignal:3.2.2

Error output:

Building native extensions. This could take a while...
ERROR:  Error installing appsignal:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/appsignal-3.2.2/ext
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 extconf.rb
/usr/local/lib/ruby/3.1.0/psych.rb:455:in `parse_stream': undefined method `parse' for #<Psych::Parser:0x0000ffffa35c9628 @handler=#<Psych::Handlers::DocumentStream:0x0000ffffa35c9b78 @stack=[], @last=nil, @root=nil, @start_line=nil, @start_column=nil, @end_line=nil, @end_column=nil, @block=#<Proc:0x0000ffffa35c96f0 /usr/local/lib/ruby/3.1.0/psych.rb:399>>, @external_encoding=0> (NoMethodError)

      parser.parse yaml, filename
            ^^^^^^
	from /usr/local/lib/ruby/3.1.0/psych.rb:399:in `parse'
	from /usr/local/lib/ruby/3.1.0/psych.rb:323:in `safe_load'
	from /usr/local/lib/ruby/3.1.0/psych.rb:369:in `load'
	from /usr/local/bundle/gems/appsignal-3.2.2/ext/base.rb:12:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from extconf.rb:1:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/bundle/gems/appsignal-3.2.2 for inspection.
Results logged to /usr/local/bundle/extensions/aarch64-linux-musl/3.1.0/appsignal-3.2.2/gem_make.out

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Please try out this new version and let us know if it works or not!

I just installed the newest gem in all our apps @tombruijn and there’s no trace of this issue anymore. 👍

I’ve reported it with Ruby upstream: https://bugs.ruby-lang.org/issues/19371

I’ve released the fix for this in AppSignal for Ruby gem 3.3.2.

Only caveat: We try to read the .gemrc file, but if this can’t be done because of this issue it’s ignored. Instead use the HTTP_PROXY env var.

Please try out this new version and let us know if it works or not!

@tijn no worries. I also forgot to mention I tested our YAML-less install on Ruby 3.2 with pysch 5 and that does work. Meaning upgrading Ruby to version 3.2 is also an option.

We are compatible with psych 5, it’s just that any Ruby version with version 4 in the standard library doesn’t work, which is most Rubies.

I’ve submitted another part of the fix in PR #914. The two PRs #913 and #914, when merged, should fix it.

@tombruijn, for us, psych 5 gets installed because rdoc depends on it. Bundler simply tries to install the latest version.

Appsignal doesn’t list psych in the gemspec (because it’s already installed with Ruby?) but rdoc explicitly specifies their dependency like such:

s.add_dependency 'psych', '>= 4.0.0'

I think that this issue can be resolved if AppSignal too could write out the dependency on psych but with an extra requirement since AppSignal appears to be incompatible with the newest version:

s.add_dependency 'psych', '>= 4.0.0', '< 5.0.0'

This will also stop dependabot from trying to upgrade libraries that cannot be upgraded.

Looks good on my deploys! cheers!

Finally reproduced! I needed to make very sure that psych5 was installed first by bundler, which didn’t always happen for some reason 🤷‍♂️

A better way to test this is to first bundle without AppSignal and then with AppSignal in the Gemfile.

crap… @manuelvanrijn, you beat me to it! 😛

Created an repo which also can reproduces the error: https://github.com/Memoriam-tv/appsignal-ruby-test-report/actions