ruby/psych

yaml.h not found and psych.rb:455:in `parse_stream`: undefined method `parse` for #<Psych::Parser

dorianmariecom opened this issue ยท 9 comments

Hi,

I'm getting two different errors on different environments (both Linux) when upgrading to Psych 5 but it works fine on macOS.

First error is:


I'm getting this output when upgrading psych from 4 to 5:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
494 |  
495 | current directory: /usr/local/bundle/gems/skylight-5.3.4/ext
496 | /usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r
497 | ./siteconf20221205-17-o7zxoa.rb extconf.rb
498 | musl libc (x86_64)
499 | Version 1.2.3
500 | Dynamic Program Loader
501 | Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname
502 | *** extconf.rb failed ***
503 | Could not create Makefile due to some reason, probably lack of necessary
504 | libraries and/or headers.  Check the mkmf.log file for more details.  You may
505 | need configuration options.
506 |  
507 | Provided configuration options:
508 | --with-opt-dir
509 | --without-opt-dir
510 | --with-opt-include
511 | --without-opt-include=${opt-dir}/include
512 | --with-opt-lib
513 | --without-opt-lib=${opt-dir}/lib
514 | --with-make-prog
515 | --without-make-prog
516 | --srcdir=.
517 | --curdir
518 | --ruby=/usr/local/bin/$(RUBY_BASE_NAME)
519 | /usr/local/lib/ruby/3.1.0/psych.rb:455:in `parse_stream': undefined method
520 | `parse' for #<Psych::Parser:0x00007f870c732950
521 | @handler=#<Psych::Handlers::DocumentStream:0x00007f870c732b58 @stack=[],
522 | @last=nil, @root=nil, @start_line=nil, @start_column=nil, @end_line=nil,
523 | @end_column=nil, @block=#<Proc:0x00007f870c7329c8
524 | /usr/local/lib/ruby/3.1.0/psych.rb:399>>, @external_encoding=0> (NoMethodError)
525 |  
526 | parser.parse yaml, filename
527 | ^^^^^^
528 | from /usr/local/lib/ruby/3.1.0/psych.rb:399:in `parse'
529 | from /usr/local/lib/ruby/3.1.0/psych.rb:324:in `safe_load'
530 | from /usr/local/lib/ruby/3.1.0/psych.rb:370:in `load'
531 | from /usr/local/lib/ruby/3.1.0/psych.rb:671:in `block in load_file'
532 | from /usr/local/lib/ruby/3.1.0/psych.rb:670:in `open'
533 | from /usr/local/lib/ruby/3.1.0/psych.rb:670:in `load_file'
534 | from extconf.rb:121:in `<main>'
535 | I, [2022-12-05T09:14:41.592907 #3150]  INFO -- :
536 | SKYLIGHT_HDR_PATH=/usr/local/bundle/gems/skylight-5.3.4/ext;
537 | SKYLIGHT_LIB_PATH=/usr/local/bundle/gems/skylight-5.3.4/lib/skylight/native/x86_64-linux-musl
538

And second error is:

  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
  
  current directory:
  /home/runner/work/albaik-web/albaik-web/vendor/bundle/ruby/3.1.0/gems/psych-5.0.0/ext/psych
  /opt/hostedtoolcache/Ruby/3.1.2/x64/bin/ruby -I
  /opt/hostedtoolcache/Ruby/3.1.2/x64/lib/ruby/3.1.0 -r
  ./siteconf20221205-2458-sr1mb3.rb extconf.rb
  checking for yaml.h... no
  yaml.h not found
  *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of necessary
  libraries and/or headers.  Check the mkmf.log file for more details.  You may
  need configuration options.
  
  Provided configuration options:
  	--with-opt-dir
  	--without-opt-dir
  	--with-opt-include
  	--without-opt-include=${opt-dir}/include
  	--with-opt-lib
  	--without-opt-lib=${opt-dir}/lib
  	--with-make-prog
  	--without-make-prog
  	--srcdir=.
  	--curdir
  	--ruby=/opt/hostedtoolcache/Ruby/3.1.2/x64/bin/$(RUBY_BASE_NAME)
  	--with-libyaml-source-dir
  	--without-libyaml-source-dir
  	--with-yaml-0.1-dir
  	--without-yaml-0.1-dir
  	--with-yaml-0.1-include
  	--without-yaml-0.1-include=${yaml-0.1-dir}/include
  	--with-yaml-0.1-lib
  	--without-yaml-0.1-lib=${yaml-0.1-dir}/lib
  	--with-yaml-0.1-config
  	--without-yaml-0.1-config
  	--with-pkg-config
  	--without-pkg-config
  	--with-libyaml-dir
  	--without-libyaml-dir
  	--with-libyaml-include
  	--without-libyaml-include=${libyaml-dir}/include
  	--with-libyaml-lib
  	--without-libyaml-lib=${libyaml-dir}/lib

See skylightio/skylight-ruby#437

I'm seeing undefined method `_native_parse' for #Psych::Parser:0x......

Could this be related to #541? Is libyaml-dev installed? Is it up to date (i.e. v0.2.5)?

I'm also seeing problems with missing libyaml - the Ubuntu image that dependabot uses doesn't seem to include libyaml, which makes psych 5.0.0 install fail, which means dependabot can't check my dependencies for projects that use latest psych.

Not quite sure what needs to be fixed: psych, dependabot, or the image?

Ran into the "yaml.h not found" error with the RubyInstaller for Windows which uses MINGW. For others in the same boat, you will need to run pacman -S libyaml-devel mingw-w64-ucrt-x86_64-libyaml in a MINGW prompt. After that, the upgrade to psych 5 succeeded for me.

Could this be related to #541? Is libyaml-dev installed? Is it up to date (i.e. v0.2.5)?

With libyaml-dev installed I get the same error on AWS and on GitHub Actions (related to the Skylight gem)

Anyone like me who got here via a failing github action may be interested in ruby/setup-ruby#409 and actions/runner-images#6725

@bryansoto

JFYI, on Windows, I think pacman -S mingw-w64-ucrt-x86_64-libyaml will suffice, as libyaml-devel is an MSYS package.

Quite a few packages on Ubuntu are split into 'runtime' packages (the standard one), and a 'dev' package. With MSYS2 and vcpkg, they are often a single package...

I'm still seeing the undefined method parse issue on Github Actions with the ubuntu-latest image, even after the addition of libyaml-dev in actions/runner-images#6725, but only on ruby 3.0.0. Is this a bug or am I missing another dependency?

I'm seeing this with ubuntu-20.04 and ubuntu-latest and ruby 3.1.3. I got around it by removing rdoc to get rid of the psych dependency.