ruby-on-rails - 运行 bundle install 时出现 sqlite3 错误

标签 ruby-on-rails ruby sqlite homebrew sqlite3-ruby

所以当我收到此错误时,我试图在我新创建的 Rails 应用程序中运行 bundle install:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150114-6877-1x6zk4k.rb 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

extconf failed, exit code 1

Gem files will remain installed in /var/folders/mc/qsk02mn50x96msk9zjxgzbmh0000gn/T/bundler20150114-6877-jsv17e/sqlite3-1.3.10/gems/sqlite3-1.3.10 for inspection.
Results logged to /var/folders/mc/qsk02mn50x96msk9zjxgzbmh0000gn/T/bundler20150114-6877-jsv17e/sqlite3-1.3.10/extensions/universal-darwin-14/2.0.0/sqlite3-1.3.10/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.

我当前的 sqlite3 版本:

3.8.7.4 2014-12-09 01:34:36 f66f7a17b78ba617acde90fc810107f34f1a1f2e

ruby :

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

brew :

0.9.5

更多信息:

$ which sqlite3
/usr/local/bin/sqlite3
$ whereis sqlite3
/usr/bin/sqlite3

这与我的 OS X 附带的 Ruby 2.0 和默认 Ruby 1.8 的冲突有什么关系吗?我使用的是 OS X 10.10。

我该如何解决这个问题?非常感谢!

最佳答案

检查你的 sqlite 安装位置并运行以下命令(我假设这里是/opt/local)

gem install sqlite3 -- --with-sqlite3-dir=/opt/local

然后

bundle install

关于ruby-on-rails - 运行 bundle install 时出现 sqlite3 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27945123/

相关文章:

ruby - 没有将 String 隐式转换为 Integer (TypeError) 为什么会这样?

iphone - SQLite Group By 和 Order By 不起作用

ruby-on-rails - 使用 mapped_mset 时,如何在 Redis 的 ruby​​ 客户端中设置过期时间?

ruby-on-rails - 是否有内置的方法来重命名整个脚手架?

ruby - 为什么 Fixnum#size 等于 8?

c# - 没有从 visual studio 2015 中的文件中获取选项 sqlite 数据库

java - sqlite中update语句的返回值

javascript - 如何设置 number_field_tag 的样式

ruby-on-rails - Rails : on redirect to same page form submitted from, 闪存消息未显示

ruby-on-rails - 如何在已被 Rails 转义的正则表达式中转义\\?