$ bundle install:无法构建gem原生扩展

时间:2011-01-17 22:21:08

标签: ruby-on-rails

使用Snow leopard,Rails 3.0.3,ruby 1.9.2p0和RVM。在尝试安装捆绑包时,我得到:

[first_app]$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.3) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.3) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.24) 
Using actionpack (3.0.3) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.9) 
Using mail (2.2.14) 
Using actionmailer (3.0.3) 
Using arel (2.0.7) 
Using activerecord (3.0.3) 
Using activeresource (3.0.3) 
Using bundler (1.0.7) 
Using thor (0.14.6) 
Using railties (3.0.3) 
Using rails (3.0.3) 
Installing sqlite3 (1.3.3) with native extensions /Users/dawson/.rvm/rubies/ruby-1.9.2-p

0/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/dawson/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb 
checking for sqlite3.h... *** 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.

5 个答案:

答案 0 :(得分:5)

您缺少与sqlite相关的系统上的某些库。这是依赖于应安装在您的计算机上的库的宝石的常见问题。尝试安装libsqlite3-dev。

答案 1 :(得分:1)

我几乎遇到了这个问题(Snow Leopard,Ruby1.9.2-p0,RVM,Rails 3.1.0rc4,安装了开发人员工具),并通过升级到更新的Ruby补丁程序来解决它。

使用RVM,你会写:

rvm upgrade ruby-1.9.2-p180 ruby-1.9.2-p0

(180是当前的补丁,但是当您尝试此补丁时可能会有更新的补丁。请使用此处命名的稳定版本:http://www.ruby-lang.org/en/downloads/

答案 2 :(得分:0)

尝试:

gem "sqlite-ruby", "~> 1.3.1"

您可能遇到问题,因为您使用的是Ruby 1.9。据说这个宝石适用于1.9:

http://isitruby19.com/sqlite3-ruby

答案 3 :(得分:0)

使用'sudo bundle install',因为本机扩展尝试在系统目录中写入。

答案 4 :(得分:0)

  1. sudo -s
  2. export ARCHFLAGS =' - arch x86_64'
  3. export PATH = / Library / PostgreSQL / 9.1 / bin:$ {PATH}
  4. gem install pg