安装sqlite3出错,构建本地扩展宝石失败。

4
我参考了stackoverflow上的以下解决方案,但我仍然遇到了相同的问题:
(安装mysql2出错: 无法构建本地扩展宝石),
如上链接中提到的命令并未解决问题:
brew install mysql
显然,问题依然存在,返回以下输出:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal',
'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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/
    --with-sqlite3lib
    --without-sqlite3lib


Gem files will remain installed in /var/folders/fb/tvgwnxc10lq6kd5xxwcg_0nw0000gn/T/bundler20150210-28601-nw7oyi/sqlite3-1.3.10/gems/sqlite3-1.3.10 for inspection.
Results logged to /var/folders/fb/tvgwnxc10lq6kd5xxwcg_0nw0000gn/T/bundler20150210-28601-nw7oyi/sqlite3-1.3.10/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
continue.
Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling.
➜  code

我真诚地感谢您的帮助。谢谢!


你使用的是RHEL/Centos/Fedora吗?你尝试过执行yum install sqlite-devel命令吗? - jpriebe
不是,我使用的是Mac OS X Yosemite操作系统。谢谢。 - alexanderjsingleton
1个回答

5
以下命令解决了我的问题:
  1. brew unlink sqlite
  2. brew install sqlite3 --universal
  3. sudo gem install sqlite3 -- --with-sqlite3-dir=/usr/local/Cellar/sqlite/3.8.8.1
我的资深信息安全工程师朋友帮我解决了问题。他说我的SQLite3更新指向了错误的bin目录。希望这对任何遇到相同烦人问题的人有所帮助。谢谢!

1
这对我非常有效。我执行了 sudo gem install sqlite3 -- --with-sqlite3-dir=/usr/local/Cellar/sqlite/3.8.10.2 命令。我的操作系统是Yosemite。 - Max
你必须始终检查使用 ls -l /usr/local/Cellar/sqlite/ 命令安装的版本,并使用最新版本的文件夹。 - sja

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接