rubyjs / mini_racer

Minimal embedded v8
MIT License
585 stars 91 forks source link

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

Closed overtube closed 10 months ago

overtube commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago
lloeki commented 1 year ago

Have you seen this before, @lloeki?

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

tisba commented 1 year ago

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 commented 10 months ago

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

gravitystorm commented 8 months ago

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 https://github.com/rubygems/rubygems/pull/6490 for the PR in rubygems that fixed this bug, which was released in rubygems 3.4.10 .

tisba commented 8 months ago

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.