【问题标题】:How do I install SQlite3 for Ruby on Rails while using RVM如何在使用 RVM 时为 Ruby on Rails 安装 SQlite3
【发布时间】:2011-07-12 23:06:41
【问题描述】:

我是编程和 Ruby on Rails 的新手。设置我的开发环境简直就是地狱。我目前的问题是安装 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

【问题讨论】:

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


【解决方案1】:

这是来自HEROKU - cannot run git push heroku master的更好答案

由于您不能在 heroku 上使用 sqlite3,请将其添加到您的 Gemfile:

group :production do
  gem 'pg'
end
group :development, :test do
  gem 'sqlite3'
end

【讨论】:

    【解决方案2】:

    您缺少用于安装 sqlite3 的共享库。

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

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

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

    如果您在安装 gem 时仍然遇到问题,试试这个 - 将 sudo 放到行中,然后进行 gem install

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

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

    在运行 sqlite3 的库之前先运行它:

    sudo apt-get update
    sudo apt-get upgrade
    

    运行更新和升级可能需要几分钟时间。您也可以从 Admin --> System area 运行它。有一个菜单可让您运行所有库更新并检查可能缺少的依赖项。

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

    请记住,当某些东西没有像您在使用 Ruby on Rails 时遇到的问题那样安装时,这通常意味着缺少库或需要的版本不正确。

    【讨论】:

    • @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 - 对不起,伙计,忘了你正在运行 RVM。我已经为你更新了答案
    • @IanN。我无法注意到您所做的更改。很抱歉打扰了。
    • @OoTheNigeria - 我在 sudo gem install sqlite3-ruby -- --with-sqlite3-dir=..... 下添加了一个新行
    • 像魅力一样工作。感谢捆绑@IanN。我非常喜欢 StackOverflow。
    猜你喜欢
    • 1970-01-01
    • 2013-05-21
    • 2019-08-08
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 2013-05-13
    • 1970-01-01
    相关资源
    最近更新 更多