【问题标题】:How can you solve the mini_racer 0.2.4 compilation issue to solve a Bundler dependency on Fedora 31?如何解决 mini_racer 0.2.4 编译问题以解决对 Fedora 31 的 Bundler 依赖?
【发布时间】:2020-04-06 17:48:05
【问题描述】:

登陆一个现有的 Rails 项目,我在设置环境时遇到了一些困难,这让我脑海中冒出了臭名昭著的“依赖地狱”。不过,它似乎仅限于 mini_racer 0.2.4。

事情是这样的:

bundle install
# […] lot of working stuffs
Fetching libv8 6.7.288.46.1 (x86_64-linux)
Installing libv8 6.7.288.46.1 (x86_64-linux)
# […] more working stuffs
Fetching mini_racer 0.2.4
Installing mini_racer 0.2.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.


    current directory: /home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/gems/mini_racer-0.2.4/ext/mini_racer_extension
/home/psychoslave/.rvm/rubies/ruby-2.5.1/bin/ruby -I /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20200404-68221-1tr6jr3.rb extconf.rb
checking for -lpthread... yes
creating Makefile

current directory: /home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/gems/mini_racer-0.2.4/ext/mini_racer_extension
make "DESTDIR=" clean

current directory: /home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/gems/mini_racer-0.2.4/ext/mini_racer_extension
make "DESTDIR="
compiling mini_racer_extension.cc
cc1plus: warning: command line option '-Wimplicit-int' is valid for C/ObjC but not for C++
mini_racer_extension.cc: In function 'void prepare_result(v8::MaybeLocal<v8::Value>, v8::TryCatch&, v8::Isolate*, v8::Local<v8::Context>, EvalResult&)':
mini_racer_extension.cc:234:73: error: no matching function for call to 'v8::Value::ToObject()'
  234 |                         String::NewFromUtf8(isolate, "JSON"))->ToObject();
      |                                                                         ^
In file included from mini_racer_extension.cc:4:
/home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/gems/libv8-7.3.492.27.1-x86_64-linux/vendor/v8/include/v8.h:2390:44: note: candidate: 'v8::MaybeLocal<v8::Object>
v8::Value::ToObject(v8::Local<v8::Context>) const'
 2390 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
      |                                            ^~~~~~~~
[…]
[A lot of other compiling errors]
[…]
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-self-assign'
cc1plus: warning: unrecognized command line option '-Wno-constant-logical-operand'
cc1plus: warning: unrecognized command line option '-Wno-parentheses-equality'
make: *** [Makefile:210: mini_racer_extension.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/gems/mini_racer-0.2.4 for inspection.
Results logged to /home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/extensions/x86_64-linux/2.5.0/mini_racer-0.2.4/gem_make.out

An error occurred while installing mini_racer (0.2.4), and Bundler cannot continue.
Make sure that `gem install mini_racer -v '0.2.4' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  mini_racer

浏览网页,很容易找到mini-racer failing to compile · Issue #4 · jules2689/extended_bundler-errorsAdd mini_racer handling。从这里我尝试了gem uninstall libv8 &amp;&amp; gem install mini_racer -v '0.2.4' --source 'https://rubygems.org/,但它无法像上面那样编译。

现在,运行bundle update &amp;&amp; bundle install 就像是一种魅力,所以我想我现在可以继续使用它,并与团队的其他成员一起看看我们是否可以至少更新迷你赛车宝石。然后我开始完成 README.md 以添加一些细节,并想在新分支中提交并要求审查。但碰巧团队使用 overcommit 添加了一些崩溃的 git 钩子,因为它包括依赖于 mini_racer-0.2.4 的 Brakeman:

git commit -m"Add more detailed procedure on how to install on Fedora 31"
Running pre-commit hooks
Analyze with RailsBestPractices..................[RailsBestPractices] OK
Check for vulnerable versions of gems...................[BundleAudit] WARNING
Run Brakeman...............................................[Brakeman] FAILED
/home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:91:in `block in materialize': Could not find mini_racer-0.2.4 in any of the sources (Bundler::GemNotFound)
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `map!'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/spec_set.rb:85:in `materialize'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:170:in `specs'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:237:in `specs_for'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/definition.rb:226:in `requested_specs'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:108:in `block in definition_method'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:20:in `setup'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler.rb:107:in `setup'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/setup.rb:20:in `<top (required)>'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/psychoslave/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require'

Run YarnLint...............................................[YarnLint] OK

✗ One or more pre-commit hooks failed

开发平台总结:

  • Fedora 31 带有开箱即用的 GCC 9.3.1 20200317 (Red Hat 9.3.1-1)
  • RVM 1.29.10
  • 捆绑器版本 1.17.3
  • Ruby 2.5.1p57(2018-03-29 修订版 63029)[x86_64-linux]
  • Rails 5.2.2
  • 路径:/home/psychoslave/.rvm/gems/ruby-2.5.1@the_project/bin:/home/psychoslave/.rvm/gems/ruby-2.5.1@global/bin:/home/psychoslave/ .rvm/rubies/ruby-2.5.1/bin:/home/psychoslave/.local/bin:/home/psychoslave/.local/bin:/home/psychoslave/bin:/home/psychoslave/.local/bin: /home/psychoslave/.config/nvm/versions/node/v8.12.0/bin:/home/psychoslave/.local/bin:/home/psychoslave/.local/bin:/home/psychoslave/bin:/usr/共享/模块/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/psychoslave/.rvm/bin
  • LIBRARY_PATH、CPATH、C_INCLUDE_PATH、CPLUS_INCLUDE_PATH 为空

您建议采取哪些步骤来解决此依赖问题?

【问题讨论】:

  • Brakeman 不依赖于 mini_racer,甚至是传递性的......

标签: c++ ruby-on-rails dependencies rubygems v8


【解决方案1】:

不管怎样,我们的团队只运行了bundle update mini_racer,现在一切正常。当然,它仍然无法在 Fedora 31 上编译 mini_racer 0.2.4。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-02
    • 1970-01-01
    • 2019-09-02
    • 2019-06-07
    • 2023-02-21
    • 2017-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多