gem安装软件时遇到的问题以及解决思路
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gem安装软件时遇到的问题以及解决思路相关的知识,希望对你有一定的参考价值。
今天需要在由于工作需要,需要使用bundle install来更新依赖包,本以为很顺利,结果遇到了下面的一堆问题,在此进行记录并分享自己遇到这个问题时的思路:
问题一:用gem安装ruby的包时出错
[email protected]:~/Desktop# gem install nokogiri -v ‘1.6.8.1‘ Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri /usr/bin/ruby2.3 -r ./siteconf20171027-10596-epcpmc.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.1.0 checking for gzdopen() in -lz... no zlib is missing; necessary for building 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=/usr/bin/$(RUBY_BASE_NAME)2.3 --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8.1 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/gem_make.out
问题描述:
gem开始尝试安装,然后依次出现以下错误: 1.安装nokogiri失败; 2.构建gem本地拓展失败; 然后,gem开始检查为什么失败: 1.checking if the C compiler accepts ... yes 2.checking for gzdopen() in -lz... no 在这里发现问题,于是gem给出失败的原因: zlib is missing; necessary for building libxml2 所以说,问题的根据点在于如何安装zlib。
思路:(系统为Linux)
1.直接啃错误信息,不要怂就是看。经过翻译之后发现直接原因是gzdopen()函数没有,这个函数没有 是因为缺少了一个包:zlib,错误描述为:zlib is missing; necessary for building libxml2。根 据Linux的一贯作风,缺什么装什么就行。 2.发现原因之后,可以直接去百度当前系统如何安装zlib,但是,因为我有apt-get可以使用,于是, 直接上:apt-get install zlib加tag减,看一下都有哪些与zlib有关的可以直接安装的东西,发现了4 个:zlib1g zlib1g-dbg zlib1g-dev zlibc 因为我这里需要调用zlib中的内容,本能的安装开发者包:zliblg-dev: apt-get install zliblg-dev 然后发现,问题被巧妙的解决了。
问题二:用gem安装Ruby包又出错了
[email protected]:~/Desktop# gem install pg -v ‘0.20.0‘ Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.3.0/gems/pg-0.20.0/ext /usr/bin/ruby2.3 -r ./siteconf20171026-3597-1h17ktg.rb extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. checking for libpq-fe.h... no Can‘t find the ‘libpq-fe.h header *** 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/bin/$(RUBY_BASE_NAME)2.3 --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.20.0/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.20.0 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.20.0/gem_make.out
解决方案:(这里的问题与上面的类似,于是先采用类似的方案尝试解决。最终解决方案如下)
apt-get install libpq-dev
问题三:强大的gem
[email protected]:~/Desktop# gem install sqlite3 -v ‘1.3.13‘ Building native extensions. This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3 /usr/bin/ruby2.3 -r ./siteconf20171026-6745-18q3rtn.rb extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try ‘brew install sqlite3‘, ‘yum install sqlite-devel‘ or ‘apt-get install libsqlite3-dev‘ and check your shared library search path (the location where your sqlite3 shared library is located). *** 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/bin/$(RUBY_BASE_NAME)2.3 --with-sqlite3-config --without-sqlite3-config --with-pkg-config --without-pkg-config --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.3.0/gems/sqlite3-1.3.13 for inspection.
解决方案:
这个例子中,有意思的地方在于gem不仅告诉你出现问题的原因,还给出了解决方案: sqlite3.h is missing. Try ‘brew install sqlite3‘,‘yum install sqlite-devel‘ or ‘apt-get install libsqlite3-dev‘ and check your shared library search path (the location where your sqlite3 shared library is located). 这里给我的经验就是,一定要直接读错误信息,一定要读,一定要读。
本文出自 “execute” 博客,请务必保留此出处http://executer.blog.51cto.com/10404661/1976896
以上是关于gem安装软件时遇到的问题以及解决思路的主要内容,如果未能解决你的问题,请参考以下文章