Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error installing mini_racer: ERROR: Failed to build gem native extension #289

Closed
overtube opened this issue Jun 23, 2023 · 7 comments
Closed

Comments

@overtube
Copy link

gem_make.out

/home/ui/.rbenv/versions/3.1.2/bin/ruby -I /home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0 -r ./siteconf20230623-28076-xc2we6.rb extconf.rb
checking for -lpthread... yes
*** 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=/home/ui/.rbenv/versions/3.1.2/bin/$(RUBY_BASE_NAME)
	--with-pthread-dir
	--without-pthread-dir
	--with-pthread-include
	--without-pthread-include=${pthread-dir}/include
	--with-pthread-lib
	--without-pthread-lib=${pthread-dir}/lib
	--with-pthreadlib
	--without-pthreadlib
	--enable-debug
	--disable-debug
	--enable-asan
	--disable-asan
/home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:455:in `parse_stream': undefined method `parse' for #<Psych::Parser:0x00007f6b17bda1d0 @handler=#<Psych::Handlers::DocumentStream:0x00007f6b17bda3b0 @stack=[], @last=nil, @root=nil, @start_line=nil, @start_column=nil, @end_line=nil, @end_column=nil, @block=#<Proc:0x00007f6b17bda248 /home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:399>>, @external_encoding=0> (NoMethodError)

      parser.parse yaml, filename
            ^^^^^^
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:399:in `parse'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb:272:in `unsafe_load'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:21:in `block in load!'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:20:in `open'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/ext/libv8-node/location.rb:20:in `load!'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/libv8-node-18.16.0.0-x86_64-linux/lib/libv8/node.rb:8:in `configure_makefile'
	from extconf.rb:77:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-linux/3.1.0/mini_racer-0.8.0/mkmf.log

extconf failed, exit code 1

mkmf.log


LD_LIBRARY_PATH=.:/home/ui/.rbenv/versions/3.1.2/lib:/usr/local/lib "gcc -o conftest -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0/x86_64-linux -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0/ruby/backward -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0 -I. -I/home/ui/.rbenv/versions/3.1.2/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC conftest.c  -L. -L/home/ui/.rbenv/versions/3.1.2/lib -Wl,-rpath,/home/ui/.rbenv/versions/3.1.2/lib -L. -L/home/ui/.rbenv/versions/3.1.2/lib  -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed     -Wl,-rpath,/home/ui/.rbenv/versions/3.1.2/lib -L/home/ui/.rbenv/versions/3.1.2/lib -lruby  -lm  -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

LD_LIBRARY_PATH=.:/home/ui/.rbenv/versions/3.1.2/lib:/usr/local/lib "gcc -o conftest -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0/x86_64-linux -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0/ruby/backward -I/home/ui/.rbenv/versions/3.1.2/include/ruby-3.1.0 -I. -I/home/ui/.rbenv/versions/3.1.2/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef  -fPIC conftest.c  -L. -L/home/ui/.rbenv/versions/3.1.2/lib -Wl,-rpath,/home/ui/.rbenv/versions/3.1.2/lib -L. -L/home/ui/.rbenv/versions/3.1.2/lib  -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,--no-as-needed     -Wl,-rpath,/home/ui/.rbenv/versions/3.1.2/lib -L/home/ui/.rbenv/versions/3.1.2/lib -lruby -lpthread  -lm  -lc"
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11: 
12:   return !!argv[argc];
13: }
14: 
15: int t(void) { ; return 0; }
/* end */

--------------------

@tisba
Copy link
Collaborator

tisba commented Jun 23, 2023

This is a very weird one 🤔

What is failing here is the installation of libv8-node (here https://github.com/rubyjs/libv8-node/blob/v18.16.0.0/ext/libv8-node/location.rb#L19-L23). The NoMethodError is coming from here https://github.com/ruby/ruby/blob/v3_1_2/ext/psych/lib/psych.rb#L452-L461, which makes no sense at all to me. On first sight, I'd say there is something messed up with your Ruby environment.

Can you run these commands and show the output?

ruby -ryaml -e 'puts YAML.safe_load("---\nhello: world\n").inspect'
ruby -ryaml -e "puts Psych::Parser.new.respond_to?(:parse)"
ruby -ryaml -e 'YAML.safe_load("--- !ruby/object:Libv8::Node::Location::Vendor {}")'

The last should raise an exception (Psych::DisallowedClass) which is okay. But it should not raise NoMethodError.

Have you seen this before, @lloeki?

@overtube
Copy link
Author

  • ruby -ryaml -e 'puts YAML.safe_load("---\nhello: world\n").inspect'
    {"hello"=>"world"}
  • ruby -ryaml -e "puts Psych::Parser.new.respond_to?(:parse)"
    true
  • ruby -ryaml -e 'YAML.safe_load("--- !ruby/object:Libv8::Node::Location::Vendor {}")'
/home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/class_loader.rb:99:in `find': Tried to load unspecified class: Libv8::Node::Location::Vendor (Psych::DisallowedClass)
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/class_loader.rb:28:in `load'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/to_ruby.rb:426:in `resolve_class'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/to_ruby.rb:215:in `visit_Psych_Nodes_Mapping'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/visitor.rb:30:in `visit'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/to_ruby.rb:35:in `accept'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/to_ruby.rb:320:in `visit_Psych_Nodes_Document'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/visitor.rb:30:in `visit'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/visitor.rb:6:in `accept'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych/visitors/to_ruby.rb:35:in `accept'
	from /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych.rb:334:in `safe_load'
	from -e:1:in `<main>'

@lloeki
Copy link
Collaborator

lloeki commented Jun 23, 2023

Have you seen this before, @lloeki?

Psych::DisallowedClass yes, but I seem to recall this was addressed. NoMethodError, never.

@tisba
Copy link
Collaborator

tisba commented Jun 23, 2023

Not sure how to investigate further, but what I just noticed from your stacktraces, @overtube: When installing libv8-node the Ruby bundled psych got used. With the execution of the snippets I gave you, it was the psych gem (/home/ui/.rbenv/versions/3.1.2/lib/ruby/3.1.0/psych.rb vs /home/ui/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/psych-5.1.0/lib/psych.rb).

To get another data point, can you try this with Ruby 3.2.2?

@Alwinator
Copy link

Alwinator commented Sep 5, 2023

It worked for me after updating my ruby version from 3.0.0 to 3.2.2.

tomhughes added a commit to tomhughes/openstreetmap-website that referenced this issue Nov 18, 2023
This works around a problem where mini_racer doesn't like the psych
in the GitHub Actions images for ruby 3.0 and 3.1 but it fine with
the ruby 3.2 image that uses a newer rubygems version.

rubyjs/mini_racer#289
@gravitystorm
Copy link

For anyone else coming across this, this was caused by a bug in rubygems < 3.4.9. So you can also fix it on older versions of ruby (e.g. ruby 3.0, 3.1) by updating your version of rubygems:

gem update --system

See rubygems/rubygems#6490 for the PR in rubygems that fixed this bug, which was released in rubygems 3.4.10 .

@tisba
Copy link
Collaborator

tisba commented Nov 22, 2023

Thanks for the comment, @gravitystorm 🙏

Super difficult to make the troubleshooting guide in the README more visible. Almost all reported bugs are solved by what we have at https://github.com/rubyjs/mini_racer#supported-ruby-versions--troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants