简体   繁体   English

坚固的 gem 无法构建本机扩展

[英]rugged gem failing to build native extension

OS: Ubuntu 18.04
GCC version: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
JRuby version: 9.2.8.0
Ruby version: 2.5.3

Issue origin : Trying to install pronto gem (version 0.11.0)问题来源:尝试安装pronto gem(版本 0.11.0)

While running gem install pronto , the gem install fails at a dependant rugged gem trying to build a native extension with the following error:在运行gem install pronto ,gem 安装在依赖rugged gem 尝试构建本机扩展时失败,并出现以下错误:

-- Build files have been written to: /home/ubuntu/.rvm/gems/jruby-9.2.8.0/gems/rugged-1.0.1/vendor/libgit2/build
 -- /usr/bin/make
checking for main() in -lgit2... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

        try_do at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:456
     try_link0 at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:541
      try_link at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:556
      try_func at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:765
  have_library at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:997
  checking_for at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:942
      postpone at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:350
          open at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:320
      postpone at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:350
          open at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:320
      postpone at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:346
  checking_for at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:941
  have_library at /home/ubuntu/.rvm/rubies/jruby-9.2.8.0/lib/ruby/stdlib/mkmf.rb:992
        <main> at extconf.rb:137
*** 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/ubuntu/.rvm/rubies/jruby-9.2.8.0/bin/jruby
    --with-sha1dc
    --without-sha1dc
    --use-system-libraries
    --with-git2-dir
    --without-git2-dir
    --with-git2-include
    --without-git2-include=${git2-dir}/include
    --with-git2-lib
    --without-git2-lib=${git2-dir}/lib
    --with-git2lib
    --without-git2lib

I tried following different methods to get it working, but all of them failed with the same error:我尝试使用不同的方法来使其工作,但所有方法都失败并出现相同的错误:

  1. Independently running gem install rugged .独立运行gem install rugged
  2. cloning the rugged git repository and manually building the code.克隆rugged git 存储库并手动构建代码。
  3. building the libgit2 manually and then building the rugged repository.手动构建libgit2 ,然后构建rugged存储库。

Please let me know if a solution to this problem exists or if there is an alternate way to handle the following pronto command:请让我知道是否存在此问题的解决方案,或者是否有其他方法来处理以下 pronto 命令:
PRONTO_GITHUB_ACCESS_TOKEN=<access_token> pronto run -c origin/master -f github_pr_review

My original problem is that I want to run the rubocop version 1.17 on my pull requests using CI.我最初的问题是我想使用 CI 在我的拉取请求上运行 rubocop 1.17 版。 The rubocop should only run on the changed lines of ruby code present in the pull request, instead of running it on the whole file. rubocop 应该只在拉取请求中出现的 ruby​​ 代码的更改行上运行,而不是在整个文件上运行它。

It seems that JRuby doesn't support C extensions/libraries. JRuby 似乎不支持 C 扩展/库。 So I had to install ruby-2.5 and then install the gems manually.所以我必须安装 ruby​​-2.5,然后手动安装 gems。 Following are the steps that I did:以下是我所做的步骤:

  1. rvm install ruby-2.5.8
  2. rvm use ruby-2.5.8
  3. gem install rubocop -v 1.17.0
  4. gem install pronto -v 0.11.0
  5. gem install pronto-rubocop -v 0.11.1

Now I can execute the pronto commands successfully.现在我可以成功执行 pronto 命令了。 Sadly, can't use bundle install on this one as my Gemfile has JRuby dependant gems.遗憾的是,由于我的 Gemfile 具有依赖于 JRuby 的 gems,因此不能在这个上使用bundle install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM