rugged gem failing to build native extension - ruby

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:
Independently running gem install rugged.
cloning the rugged git repository and manually building the code.
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.

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:
rvm install ruby-2.5.8
rvm use ruby-2.5.8
gem install rubocop -v 1.17.0
gem install pronto -v 0.11.0
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.

Related

Bundler v2.0.2 refuses to install libxml-ruby 3.1.0 on Mac OS Catalina

I have found all of the answers of how to install libxml-ruby with the gem install command:
gem install libxml-ruby -v '3.1.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include
Works beautifully! But then running this right afterward:
bundle install
gives the unhelpful error:
Fetching libxml-ruby 3.1.0
Installing libxml-ruby 3.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/me/myApp/code/myApp/.gems/ruby/2.6.0/gems/libxml-ruby-3.1.0/ext/libxml
/Users/me/.rbenv/versions/2.6.3/bin/ruby -I /Users/me/.rbenv/versions/2.6.3/lib/ruby/2.6.0 -r ./siteconf20191215-25200-16wtr3.rb extconf.rb --with-xml2-config\=/usr/local/opt/libxml2/bin/xml2-config\
--with-xml2-dir\=/usr/local/opt/libxml2\ --with-xml2-lib\=/usr/local/opt/libxml2/lib\ --with-xml2-include\=/usr/local/opt/libxml2/include
/Users/me/.rbenv/versions/2.6.3/bin/ruby: warning: shebang line ending with \r may cause problems
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... *** 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=/Users/me/.rbenv/versions/2.6.3/bin/$(RUBY_BASE_NAME)
--with-xml2-config
OK, it looks like the libxml2 options are not being included in the call the bundler uses to install. So let's do this:
bundle config build.libxml-ruby --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include
That should work, right? Well no it doesn't. I am dead in the water until I can get Bundler to do what it is supposed to do.
There is no good answer for why Bundler fails here. The gem install line works. Bundler fails.
Inside the mkmf.log file is this:
find_header: checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... -------------------- no
And then several failures that all relate to not being able to find that header file.
It's looking in /opt/, instead of /usr/local/opt. I don't know how to make Bundler look in the correct place if it won't respect the bundle config commands.
Since Bundler wouldn't honor the paths I was passing in, I looked at the paths where it was looking for xmlversion.h.
I went into /usr/local/include. That's where all my Homebrew links are. I created a symlink to the Mac OS-provided libxml directory:
ln -s /usr/local/opt/libxml2/include/libxml2/libxml libxml
/usr/local/opt seems like a strange place for a system directory, but I'm tired of messing with it.
Once I did this, and went back into my app directory, bundle install worked. Well, I mean it broke again but it was on therubyracer this time. So it at least jumped this hurdle.

Ruby sqlite3 gem installation issue on Windows 10

I am very new to ruby and rails. I am trying to install to sqlite3 for trying a tutorial and having issues. I am on Windows 10 and using ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32].
Here is the installation error I am getting while running gem install sqlite3-ruby. I have also tried running gem install sqlite3 --platform=ruby -- --with-sqlite3-include=c:/sqlite3/include --with-sqlite3-lib=c:/sqlite3/lib
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20190217-3116-1d59gcv.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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=C:/Ruby26-x64/bin/$(RUBY_BASE_NAME)
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--with-pthreadlib
--without-pthreadlib
--with-dllib
--without-dllib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/sqlite3-1.4.0/mkmf.log
extconf failed, exit code 1
I have downloaded sqlite3 from their site and here is the folder structure of C:\sqlite3\
sqldiff.exe
sqlite3.exe
sqlite3_analyzer.exe
include\shell.c
include\sqlite3.c
include\sqlite3.h
include\sqlite3ext.h
lib\sqlite3.def
lib\sqlite3.dll
I have also copied sqldiff.exe, sqlite3.exe and sqlite3_analyzer.exe to C:\Ruby26-x64\bin.
In my environment variable, I have added C:\sqlite3\ to PATH and also created a new environment variable sqlite3-dir pointing to C:\sqlite3\
Could someone please provide some help for this installation problem?
adding gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec" in the project Gemfile file works. After that run bundle install. Make sure to install git in the machine. This is the github link
For solving this issue for all the projects I downloaded the gem file from https://rubygems.org/ and saved it locally, installed MinGW by cmd
C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn
and the SQLite 3 gem after
C:\Sites>gem install --local C:\sqlite3-1.4.0.gem
and it worked for all the next projects created on Sites folder if you need to fix a project already created trying running bundle install again after those lines.
I also tried including the SQLite 3 files to the path but it didn't work for me either
This is what has currently worked for me and it's a per project fix; Samiul Alam Anik's answer, but with an addition. After you follow those steps, you might get a requires Bundler 2 and this is solved for me with gem update --system thanks to this GitHub ticket.
Make sure you have current Ruby version installed on your computer, install node ja, install yarn, update npm, update gem Ruby.
C:\Users\adilkemo>ruby --version
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]
C:\Users\adilkemo>gem --version
3.2.15
C:\Users\adilkemo>node --version
v16.4.2
C:\Users\adilkemo>yarn --version
1.22.10
C:\Users\adilkemo>npm --version
7.18.1
C:\Users\adilkemo>sqlite3 --version
3.36.0 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5
C:\Users\adilkemo>gem install rails
C:\Users\adilkemo>rails --version
Rails 6.1.4
C:\Users\adilkemo>cd Desktop
C:\Users\adilkemo\Desktop>rails new blog
C:\Users\adilkemo\Desktop>cd blog
C:\Users\adilkemo\Desktop\blog>bin/rails server - Goodbye!
Exiting
Terminate batch job (Y/N)? y
C:\Users\adilkemo\Desktop\blog>
https://rubyinstaller.org/
https://guides.rubygems.org/rubygems-basics/
https://nodejs.org/en/
https://classic.yarnpkg.com/en/docs/install/#windows-stable
https://www.sqlite.org/download.html
https://guides.rubyonrails.org/v5.0/getting_started.html

Error installing Nokogiri via Bundler on Windows

I'm trying to set up and run the Extreme Startup coding dojo on my Windows machine.
When I reach the bundle install step, I get this error message:
$ bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing builder 3.2.2
Installing nokogiri 1.4.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
c:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150826-3512-ilnke5.rb extconf.rb
*** 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=c:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:10:in `<main>': uninitialized constant Config (NameError)
extconf failed, exit code 1
Gem files will remain installed in c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/nokogiri-1.4.5 for inspection.
Results logged to c:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/nokogiri-1.4.5/gem_make.out
An error occurred while installing nokogiri (1.4.5), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.4.5'` succeeds before bundling.
According to the documentation for Nokogiri, it just ought to work, and in a sense, it does, because if I issue the command gem install nokogiri, it does work, but installs nokogiri-1.6.6.2-x64-mingw32.
As I understand the error message from bundle install, it specifically wants version 1.4.5. At least, even with nokogiri-1.6.6.2-x64-mingw32 installed, bundle install still fails with the above error message.
This is likely to be a simple problem, but since I'm a novice ruby user, I could use some help.
I've already tried the suggestions from Error installing Nokogiri on bundle install but already installed, but none of them work.
This particular version of Nokogiri is listed in Gemfile.lock. You can remove that file, run bundle install again and see if it works.
This is more a workaround than a proper solution, but dependencies in Gemfile.lock are quite old so it would be a good thing to refresh them anyway.

Problems with jslint-v8 Ruby gem installation on Windows7 64-bit

There is a problem during Rally App SDK 2.0p environment setup on Windows 7 (64-bit). I have installed Ruby 1.8.7-p358 from rubyinstaller.org and managed to install rake Ruby gem. But I have problems installing jslint-v8 gem. It has dependencies on therubyracer and libv8 gems which need to be built using Ruby DevKit. During the installation I got the following error:
C:\ruby> gem install jslint-v8
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing jslint-v8:
ERROR: Failed to build gem native extension.
C:/ruby/bin/ruby.exe extconf.rb
*** 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=C:/ruby/bin/ruby
extconf.rb:13: uninitialized constant Gem (NameError)
Checking for Python...
Gem files will remain installed in C:/ruby/lib/ruby/gems/1.8/gems/libv8-3.3.10.4 for inspection.
Results logged to C:/ruby/lib/ruby/gems/1.8/gems/libv8-3.3.10.4/ext/libv8/gem_make.out
Does anyone know how to install it correctly in Win7?
Thank you!
The gem you try to install depends on libv8 gem, which is nothing more than a wrapper for Google V8 JavaScript VM.
There is no pre-compiled libv8 for Windows (like there is for Linux or OSX), this means it needs to build V8 from scratch.
The code around the build process of V8 is not very portable, not to mention that to compile libv8 you need Python installed :-P
Until today nobody was able to follow the instructions for libv8 pre-compilation on Windows, following the repository instructions:
https://github.com/cowboyd/libv8
Sorry not been able to provide you a better response.
Try this gem install libv8 -v '3.16.14.3' -- --with-system-v8
Reference: Error installing libv8: ERROR: Failed to build gem native extension
For building gem native extensions in Windows when you install a gem, you usually need the DevKit installed too:
http://rubyinstaller.org/downloads/ - go to the devkit download link
Their github page has instructions for installing it: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
I would also recommend using Ruby 1.9.3 instead of 1.8.7, but that shouldn't be much of an issue
Hope that helps.

Can't install therubyracer in JRuby

I've installed RVM and then Jruby, this the version that i get when i type: jruby -v:
jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) Client VM 1.7.0_02) [linux-i386-java]
The problem is that I can't install therubyracer gem, i get this when i try to install by jruby -S gem install therubyracer:
/usr/local/rvm/rubies/jruby-1.6.5.1/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library very we$
Check http://kenai.com/projects/jruby/pages/Home for alternatives.
Checking for Python...Unable to build libv8: Python not found!
*** 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=/usr/local/rvm/rubies/jruby-1.6.5.1/bin/jruby
I also tried with --1.9 parameter, to force to use another ruby version, but it fails anyway. Even I tried to install libv8, but i get the same error above.
Any ideas?
I have CentOS 5.7
You want the Ruby Rhino.
Just to clarify, in your Gemfile it's:
gem 'therubyrhino'
followed on the command line with:
jruby -S bundle install
I've had the same problem, but defining therubyrhino in the Gemfile didn't solve my problem, bundler kept trying to install libv8.
That happened because I defined twitter-bootstrap-rails gem in the Gemfile, and it depends on the less gem (that depends on therubyracer), so I changed the less gem to use the static branch that not depends on less (as suggested on the issue https://github.com/seyhunak/twitter-bootstrap-rails/issues/22):
gem 'twitter-bootstrap-rails', :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git", :branch => "static"

Resources