运行bundle install时sqlite3出错

时间:2015-01-14 14:21:32

标签: 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]

酿酒:

0.9.5

更多信息:

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

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

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

6 个答案:

答案 0 :(得分:10)

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

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

然后

bundle install

答案 1 :(得分:2)

所以我找到了解决方案:只需(手动)卸载计算机中任何现有版本的sqlite3。我做的是:

  1. 运行which -a sqlite3找出安装sqlite3的目录(对我来说有4个版本的O.o)。删除所有这些sqlite3文件(通过rm)
  2. 手动删除/usr/local/libusr/local/binusr/local/include
  3. 中所有与sqlite相关的文件
  4. 删除所有内容后,再次在app dir中运行bundle install,将自动安装所需的sqlite3版本。

    $bundle install Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... // Using a bunch of gems Installing sqlite3 1.3.10 Installing turbolinks 2.5.3 Installing uglifier 2.7.0 Installing web-console 2.0.0 Your bundle is complete! Use 'bundle show [gemname]' to see where a bundled gem is installed.

  5. 如果您遇到与我相同的问题,我希望这可以节省您的一些时间。谢谢!

答案 2 :(得分:0)

尝试在您的控制台中安装这些内容:

安装brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)""

# Add Homebrews binary path to the front of the $PATH
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile

brew install sqlite3
brew install libsqlite3-dev
bundle install

请检查this链接!

答案 3 :(得分:0)

我只是添加自己的解决方案,以供其他人尝试,以防上述情况对他们不利。

我不得不冲泡卸载sqlite3,然后不得不从rails应用目录中删除sqlite3s。

使用sudo rm -fr {app_route}/vendor/bundle/ruby/2.3.0/gems/sqlite3-1.3.13/

然后使用bundle install重新安装sqlite3。

答案 4 :(得分:0)

这在 #include <iostream> const int f1(int a) { return 15; } const int& f2(int a) { return 14; } int& f3(int a) { a = 12; return a; } int main() { auto a{ 10 }; auto b = f1(a); auto c = f2(a); auto d = f3(a); std::cout << a << " " << b << " " << c << " " << d << std::endl; a = 1; b = 2; c = 3; d = 4; std::cout << a << " " << b << " " << c << " " << d << std::endl; } 关于 debian 风格的上下文中对我有用:

Dockerfile

.. 成功了!

答案 5 :(得分:-1)

当您尝试创建新项目时,rails会尝试使用最新版本的rails创建。因此,bundle install引发了一些错误。

创建新项目时,您可以指定已安装到OS X的rails的版本,如下所示。

$ rails -v
Rails 4.x.x

之后,您可以创建如下的新项目。

$ rails _4.x.x_ new PROJECT_NAME