2011-02-17 168 views
16

我想在OS X 10.6上安裝「sqlite3-ruby」寶石(或「sqlite3」寶石)。我使用的紅寶石1.9.2和我目前得到如下:sqlite3寶石未能安裝

$ sqlite3 --version 
3.7.4 
$ sudo gem install sqlite3 
Building native extensions. This could take a while... 
ERROR: Error installing sqlite3-ruby: 
    ERROR: Failed to build gem native extension. 

/Users/folken/.rvm/rubies/ruby-1.9.2-head/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. 

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=/Users/folken/.rvm/rubies/ruby-1.9.2-head/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}/lib 
/Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:276:in `postpone' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for' 
    from /Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:852:in `find_header' 
    from extconf.rb:28:in `<main>' 


Gem files will remain installed in /Users/folken/.rvm/gems/ruby-1.9.2-head/gems/sqlite3-1.3.3 for inspection. 

以下是其中的& whereis和sqlite3.h位於在/ opt /本地/包括結果:

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

我試圖通過在下面還有:

sudo gem install sqlite3 -- --with-sqlite3-include /opt/local/include --with-sqlite3-lib /opt/local/lib 
sudo gem install sqlite3 -- --with-sqlite3-dir /opt/local/bin 

其結果如下:

ERROR: Error installing sqlite3-ruby: 
    ERROR: Failed to build gem native extension. 

/Users/folken/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb --with-sqlite3-dir /usr/bin/sqlite3 
*** 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=/Users/folken/.rvm/rubies/ruby-1.9.2-head/bin/ruby 
    --with-sqlite3-dir 
/Users/folken/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:1336:in `dir_config': undefined method `split' for true:TrueClass (NoMethodError) 
    from extconf.rb:9:in `<main>' 

此外,根據/U​​sers/folken/.rvm/gems/ruby-1.9.2-head/gems: 的sqlite-紅寶石2.2.3 sqlite3-1.3.3

在RVM我有紅寶石-1.8.7和sqlite3的寶石加載罰款,但經過大量的谷歌搜索,我還沒有找到一個適合我的解決方案。任何幫助非常感謝(即使它涉及手動安裝/ hackery工作)。

+1

你檢查了makefile日誌嗎?它包含了什麼? – jergason 2011-02-17 06:23:14

+0

你有gcc嗎?嘗試在你的shell中輸入gcc – 2011-02-17 06:27:22

回答

3

聽起來像你還沒有安裝XCode。

13

我有一個幾乎相似的問題,因爲你我已經安裝了sqlite3,但sqlite3寶石不會安裝。我看到一個錯誤信息如下,

user-name-rajas-macbook-pro:rails3 user-namer$ gem install sqlite3 
Building native extensions. This could take a while... 
    ERROR: Error installing sqlite3: 
    ERROR: Failed to build gem native extension. 

     /Users/user-namer/.rvm/rubies/ruby-1.9.2-p180/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' 
or 'yum install sqlite3-devel' 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 
    --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=/Users/user-namer/.rvm/rubies/ruby-1.9.2-p180/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}/lib 
    --with-sqlite3lib 
    --without-sqlite3lib 


Gem files will remain installed in /Users/user-namer/.rvm/gems/ruby-1.9.2- [email protected]_3/gems/sqlite3-1.3.3 for inspection. 
Results logged to /Users/user-namer/.rvm/gems/[email protected]_3/gems/sqlite3- 1.3.3/ext/sqlite3/gem_make.out 

這裏是爲我工作

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

我是繼Rails3中行動的書用紅寶石1.9.2.p180 RVM和導軌3.1。 0.rc6使用Mac OS X 10.5.8(Leopard)的,當我跑:

rake cucumber:ok 

我:

Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (can't activate sqlite3 (~> 1.3.4, runtime), already activated sqlite3-1.3.3. Make sure all dependencies are added to Gemfile.) 

我然後做:

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

其次:

bundle install 

希望,我會在互聯網上找到我自己的答案是必需的SQLite 1.3.5時。

2

對於osx,請確保您已安裝Xcode並且已接受這些條款。對我而言,我沒有同意這些條款(無論出於何種原因,或許最近我的電腦上安裝或更新了Xcode)。

  1. 開放的Xcode
  2. 如果彈出出現,然後同意條款(如果你沒有得到一個彈出,那麼你可能已經接受的條款)。