rugged gem failing to build native extension

639 Views Asked by At
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)

While running gem install pronto, the gem install fails at a dependant rugged gem trying to build a native extension with the following error:

-- 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.
  2. cloning the rugged git repository and manually building the code.
  3. building the libgit2 manually and then building the rugged repository.

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_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. 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.

1

There are 1 best solutions below

0
On

It seems that JRuby doesn't support C extensions/libraries. So I had to install ruby-2.5 and then install the gems manually. 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. Sadly, can't use bundle install on this one as my Gemfile has JRuby dependant gems.