1、安装 nokogiri Failed to build gem native extension出错,提示:libxml2无法找到。

解决办法:安装libxml2即可。

安装命令:

#sudo apt-get install libxml2

#sudo apt-get install libxml2-dev

2、安装pg时出错,提示:

Building native extensions.  This could take a while…
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby2.1 extconf.rb
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
–with-pg-config=/path/to/pg_config
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/ruby2.1
–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

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/pg-0.18.1 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/pg-0.18.1/gem_make.out
ERROR:  Could not find a valid gem ‘with-pg-dir’ (>= 0) in any repository

    解决办法:跳过安装

    命令:bundle install –without production

3、无法安装sqlite3,提示:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby2.1 extconf.rb
checking for sqlite3.h… no
sqlite3.h is missing. Try ‘port install sqlite3 +universal’,
‘yum install sqlite-devel’ or ‘apt-get install libsqlite3-dev’
and chethat `gem install sqlite3 -v ‘1.3.10’` succeeds before bundling.ck 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.

    解决办法:提示信息已提供解决办法,运行3个命令即可。

安装命令:apt-get install libsqlite3-dev

 

有错误的地方都解决了,可以运行bundle update继续安装,安装完成。

发表评论

您的电子邮箱地址不会被公开。