我试图在ruby中安装OpenGraph gem

时间:2017-11-25 16:20:40

标签: ruby-on-rails ruby rubygems nokogiri opengraph

我搜索了整个网络,寻找克服此错误的方法。但它不会让步。我根据我的知识安装了所有库和依赖项,甚至卸载了ruby和nokogiri并重新安装。但这个错误仍然存​​在。



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




这是来自此位置的gem_make.out日志文件 - > /.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
&#13;
&#13;
&#13; 如果你能告诉我它有什么问题,我将非常感谢你。这是OpenGraph中的一个错误。

P.S:我没有使用opengraph_parser,因为它有一个回退方法。我需要opengraph gem,因为我需要捕获异常。

1 个答案:

答案 0 :(得分:0)

这不是opengraph,而是nokogiri。

Nokogiri是opengraph的依赖。 https://rubygems.org/gems/opengraph/versions/0.0.4

因此,它必须与您的机器相关,而不具备支持nokogiri(libxml2)所需的依赖项。

在您的计算机上安装这些依赖项(假设您的 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)

然后尝试按gem install nokogiri

安装nokogiri

对于其他变体或操作系统: http://www.nokogiri.org/tutorials/installing_nokogiri.html

对于Fedora 26: 直到另行通知,安装nokogiri版本&lt; 1.8