使用RVM时如何为Ruby on Rails安装SQlite3

使用RVM时如何为Ruby on Rails安装SQlite3

问题描述:

我是编程和Ruby on Rails的新手.设置我的开发环境一直很艰难.我目前的问题是安装Sqlite 3.

I am new to programming and Ruby on Rails. Setting up my dev environment has been hell. My present issue is installing Sqlite 3.

当我这样做

$ 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/ruby-1.9.2-p180@rails3tutorial/gems/sqlite3-1.3.3 for inspection.
Results logged to /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/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/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/bin/bundle:19:in `load'
    from /home/oo/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/bin/bundle:19:in `<main>'

我正在使用Ubuntu 10.10

I am using Ubuntu 10.10

您缺少安装sqlite3的共享库.

You are missing shared libraries to install sqlite3.

大多数ROR安装说明或教程可能没有告诉您的一件事是,当在Linux上运行时,您需要共享库,或者Windows Person dll是否丢失或与您尝试运行的版本不兼容.

Probably one thing that most ROR install instructions or tutorials don't tell you is that when running on Linux you need shared libraries or if your a windows person dll's are missing or incompatible with the version you are trying to run.

我看到您也在运行RVM.所以你应该试试这个.

I see you are running RVM also. So you should try this.

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

如果您仍然无法安装gem,请尝试以下操作-将sudo放到行中,然后仅安装gem

If you still have trouble installing the gem try this - drop the sudo in the line and just gem install

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

此外,为Ubuntu更新所有库也没有什么坏处.

Additionally it doesn't hurt to update all your libraries for Ubuntu.

先运行此命令,然后再运行sqlite3的库:

Run this first before running the libraries for sqlite3:

sudo apt-get update
sudo apt-get upgrade

运行更新和升级可能需要几分钟.您也可以从管理"->系统"区域运行此程序.有一个菜单可让您运行所有库更新并检查可能缺少的依赖项.

It will probably take some minutes to run the update and upgrade. You can also run this from the Admin --> System area . There is a menu that allows you to run all library updates and checks for dependencies which may be missing.

您还可以从系统应用程序GUI运行sqlite安装,因为它将检查可能也需要的依赖程序.

You could also run the sqlite install from the system applications GUI, as it will check dependency programs which may also be needed.

请记住,当未安装某些东西(例如您在Ruby on Rails中遇到的问题)时,通常意味着缺少库或所需的版本不正确.

Just remember when something doesn't install like the issue you are having with Ruby on Rails, it usually means that libraries are missing or the incorrect version needed.