2011-03-10 79 views
9

我是編程和Ruby on Rails的新手。設置我的開發環境一直是地獄。我現在的問題是安裝SQLite的3如何在使用RVM時爲Ruby on Rails安裝SQlite3

當我做

$ bundle install 

我得到

Fetching source index for http://rubygems.org/ 
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.1) 
Using builder (2.1.2) 
Using i18n (0.4.2) 
Using activemodel (3.0.1) 
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.1) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.9) 
Using mail (2.2.15) 
Using actionmailer (3.0.1) 
Using arel (1.0.1) 
Using activerecord (3.0.1) 
Using activeresource (3.0.1) 
Using bundler (1.0.10) 
Using thor (0.14.6) 
Using railties (3.0.1) 
Using rails (3.0.1) 
Installing sqlite3 (1.3.3) with native extensions /home/oo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     /home/oo/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb 
checking for sqlite3.h... no 
sqlite3.h 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 
    --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=/home/oo/.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 


Gem files will remain installed in /home/oo/.rvm/gems/[email protected]/gems/sqlite3-1.3.3 for inspection. 
Results logged to /home/oo/.rvm/gems/[email protected]/gems/sqlite3-1.3.3/ext/sqlite3/gem_make.out 
    from /home/oo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:511:in `block in build_extensions' 
    from /home/oo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `each' 
    from /home/oo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:486:in `build_extensions' 
    from /home/oo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:159:in `install' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start' 
    from /home/oo/.rvm/gems/[email protected]/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>' 
    from /home/oo/.rvm/gems/[email protected]/bin/bundle:19:in `load' 
    from /home/oo/.rvm/gems/[email protected]/bin/bundle:19:in `<main>' 

我使用Ubuntu 10.10

+0

的可能重複http://stackoverflow.com/questions/3458602/ sqlite3-ruby-install-error-on-ubuntu – Groovetrain 2011-03-10 18:49:58

回答

7

你缺少共享庫安裝sqlite3的。

大多數ROR安裝說明或教程沒有告訴你的一件事情是,在Linux上運行時,您需要共享庫,或者如果您的Windows個人DLL缺少或與您嘗試運行的版本不兼容。

我看你也在運行RVM。所以你應該試試這個。

sudo apt-get install libsqlite3-dev 
sudo gem install sqlite3-ruby 

如果您仍然有麻煩安裝寶石嘗試這 - 行中刪除須藤,只是創業板安裝

gem install sqlite3-ruby -- --with-sqlite3-dir=/usr/local/lib 

此外,它不會傷害到更新Ubuntu的所有庫。

運行此先運行庫sqlite3的面前:

sudo apt-get update 
sudo apt-get upgrade 

這可能需要幾分鐘運行更新和升級。您也可以從管理 - >系統區域運行。有一個菜單允許您運行所有庫更新並檢查可能丟失的依賴關係。

您也可以從系統應用程序GUI運行sqlite安裝,因爲它會檢查可能也需要的依賴程序。

請記住,當某些事情沒有像Ruby on Rails一樣安裝時,通常意味着庫缺失或需要的版本不正確。

+0

@ianN我成功地做了'sudo apt-get update sudo apt-get upgrade'和'sudo apt-get install libsqlite3-dev'。但是當我做'sudo gem install sqlite3-ruby'時,我得到了響應'sudo:gem:command not found' – OoTheNigerian 2011-03-10 19:39:14

+0

@OoTheNigerian - 對不起隊友,忘了你正在運行RVM。我已經爲你更新了我的答案 – IanN 2011-03-10 19:48:02

+0

@IanN。我無法注意到你所做的改變。對不起,因爲麻煩。 – OoTheNigerian 2011-03-10 19:51:54