简体   繁体   中英

I'm trying to install OpenGraph gem in ruby

I've searched entire web looking for a way to get over this error. But it won't budge. I installed all the libraries and dependencies according to my knowledge even uninstalled ruby and nokogiri and reinstalled again. But this error remains here.

 Gem files will remain installed in /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7 for inspection. Results logged to /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/nokogiri-1.4.7/gem_make.out 

This is from the gem_make.out log file from this location -> /.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/nokogiri-1.4.7/gem_make.out

 ERROR: Error installing opengraph: ERROR: Failed to build gem native extension. current directory: /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7/ext/nokogiri /home/$User/.rbenv/versions/2.4.2/bin/ruby -r ./siteconf20171125-15877-nibcps.rb extconf.rb --with-nokogiri-dir=/home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ *** 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/$User/.rbenv/versions/2.4.2/bin/$(RUBY_BASE_NAME) extconf.rb:10:in `<main>': uninitialized constant Config (NameError) Did you mean? RbConfig CONFIG extconf failed, exit code 1 
I'd be very thankful to you if you could tell me what's wrong with it. Is it a bug in OpenGraph.

PS: I'm not using opengraph_parser because it has a fallback method. I need opengraph gem because I need to catch the exception.

It's not opengraph, but rather nokogiri.

Nokogiri is a dependency for opengraph. https://rubygems.org/gems/opengraph/versions/0.0.4

So, it must be related on your machine not having the dependencies needed to support nokogiri (libxml2).

Install these dependencies on your machine (assuming your on Debian/Ubuntu ):

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev

Fedora/Red Hat/CentOS:

sudo yum install -y gcc ruby-devel zlib-devel
sudo yum install -y rubygem-nokogiri (alternative)

Then try installing nokogiri by gem install nokogiri

For other variants, or OS: http://www.nokogiri.org/tutorials/installing_nokogiri.html

For Fedora 26: Until further notice, install nokogiri version < 1.8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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