无法安装sqlite3并运行bundle install

时间:2016-04-11 18:59:18

标签: ruby-on-rails ruby ruby-on-rails-3 sqlite

我正在使用sqlite3开发Ruby on Rails应用程序,当我运行bundle install时,出现此错误:

Installing sqlite3 1.3.11 with native extensions

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

current directory: /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/gems/sqlite3-1.3.11/ext/sqlite3/usr/bin/ruby1.9.1 -r ./siteconf20160411-6894-cji211.rb extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
    from extconf.rb:3:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/gems/sqlite3-1.3.11 for inspection.
Results logged to /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/extensions/x86_64-linux/1.9.1/sqlite3-1.3.11/gem_make.out
Using erubis 2.6.6
Using activemodel 3.0.5
Using rack-mount 0.6.14
Using rack-test 0.5.7
Using treetop 1.4.15
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.

Gemfile

source 'http://rubygems.org'

gem 'rails', '3.0.5'

gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'

我有什么想法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:2)

您需要先安装sqlite3 sudo apt-get install libsqlite3-dev

答案 1 :(得分:0)

您是否尝试使用Google搜索错误?

以下是您遇到的同一错误的答案。

Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)

解决方案不适用于sqlite3。这很可能是你的-dev包。如果你在Linux上试试这个 -

sudo apt-get install ruby-dev

对于Mac,请尝试此

brew install ruby-dev