【问题标题】:Starting the rails, sqlite3 Error启动rails,sqlite3错误
【发布时间】:2013-10-02 14:55:36
【问题描述】:

在检查我的系统是否满足最低要求后,我开始检查版本是否合适: rails new app 当新应用程序归零时,我收到消息 NEXT:

         run  bundle install
/var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/ui.rb:36:in `initialize': undefined method `[]' for #<Thor::Shell::Color:0x95890e0> (NoMethodError)
    from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:12:in `new'
    from /usr/lib/ruby/vendor_ruby/bundler/cli.rb:12:in `initialize'
    from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:263:in `new'
    from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:263:in `dispatch'
    from /usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:386:in `start'
    from /var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:in `block in <main>'
    from /var/lib/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
    from /var/lib/gems/1.9.1/gems/bundler-1.3.5/bin/bundle:20:in `<main>'

进入新创建的 Rails 应用程序。我运行bundle install 然后开始安装并收到以下错误消息:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb 
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-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=/usr/bin/ruby1.9.1
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local


Gem files will remain installed in /home/helio/.bundler/tmp/23089/gems/sqlite3-1.3.8 for inspection.
Results logged to /home/helio/.bundler/tmp/23089/gems/sqlite3-1.3.8/ext/sqlite3/gem_make.out

An error occurred while installing sqlite3 (1.3.8), and Bundler
cannot continue.
Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before
bundling.

我已经尝试过,但是当我尝试安装 splite3 时收到错误消息:

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-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=/usr/bin/ruby1.9.1
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local


Gem files will remain installed in /var/lib/gems/1.9.1/gems/sqlite3-1.3.8 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/sqlite3-1.3.8/ext/sqlite3/gem_make.out

【问题讨论】:

  • 我也试过写两行来提示消息:port install sqlite3 +universalyum install sqlite-devel,没有那些不起作用。

标签: ruby-on-rails sqlite


【解决方案1】:

你需要先在你的系统上安装 sqlite3。 Rails 缺少这里的库。

【讨论】:

  • 在尝试安装 sqlite3 后只需编辑带有结果的条目
  • sqlite3 已安装SQLite version 3.7.13 2012-06-11 02:05:22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite&gt;
【解决方案2】:

问题出在 Gemfile 中。教程中有一条注释说:默认情况下,Windows 和 Mac 也安装了 java 运行时脚本。相反,linux 没有携带它。它必须单独安装。但是很容易解决 首先是清除 Gemfile 中引用运行时的行。 第二个是bundle install。运行这个命令的Bundler安装了必要的软件和boala,解决了。

【讨论】:

    【解决方案3】:

    我遇到了同样的错误,试图启动一个新的 Rails 项目。在这种情况下sqlite3.h is missing,意味着 libsqlite3-dev 丢失了,我猜(我是 Ubuntu 和 Sqlite3 的新手)。答案可以在这里找到:Installing sqlite headers

    ~$ sudo apt-get install sqlite3
    ~$ sudo apt-get install libsqlite3-dev
    ~$ bundle install
    

    在那之后,rails server 对我来说效果很好。我的 Welcome onboard 在 localhost 中。

    【讨论】:

      【解决方案4】:

      对我来说,我得到了错误(在 MacOS 上),结果证明是缺少 GNU MP 库。

      这在 ~/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/mkmf.log 文件中提到

      -lgmp 丢失

      brew 显示这些库是存在的,但我认为 Xcode 想知道:

      我的踪迹...

      $ brew install gmp 警告:gmp-6.0.0a 已经安装 ✔ ~/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9

      $ brew install gmp4 警告:gmp4-4.3.2 已经安装 ✔ ~/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9

      $ ls -altd /usr/local/lib/libgmp* lrwxr-xr-x 1 si 工作人员 40 Jul 31 15:48 /usr/local/lib/libgmp.10.dylib -> ../Cellar/gmp/6.0.0a/lib/libgmp.10.dylib lrwxr-xr-x 1 si 工作人员 33 Jul 31 15:48 /usr/local/lib/libgmp.a -> ../Cellar/gmp/6.0.0a/lib/libgmp.a lrwxr-xr-x 1 si 工作人员 31 年 7 月 37 日 15:48 /usr/local/lib/libgmp.dylib -> ../Cellar/gmp/6.0.0a/lib/libgmp.dylib lrwxr-xr-x 1 si 工作人员 41 Jul 31 15:48 /usr/local/lib/libgmpxx.4.dylib -> ../Cellar/gmp/6.0.0a/lib/libgmpxx.4.dylib lrwxr-xr-x 1 si 工作人员 35 Jul 31 15:48 /usr/local/lib/libgmpxx.a -> ../Cellar/gmp/6.0.0a/lib/libgmpxx.a lrwxr-xr-x 1 si 工作人员 31 年 7 月 39 日 15:48 /usr/local/lib/libgmpxx.dylib -> ../Cellar/gmp/6.0.0a/lib/libgmpxx.dylib ✔ ~/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9

      $ otool -L /usr/local/lib/libgmpxx.dylib /usr/local/lib/libgmpxx.dylib: /usr/local/lib/libgmpxx.4.dylib(兼容版本 9.0.0,当前版本 9.0.0) /usr/local/Cellar/gmp/6.0.0a/lib/libgmp.10.dylib(兼容版本13.0.0,当前版本13.0.0) /usr/lib/libc++.1.dylib(兼容版本 1.0.0,当前版本 120.0.0) /usr/lib/libSystem.B.dylib(兼容版本 1.0.0,当前版本 1197.1.1) ✔ ~/.rvm/gems/ruby-2.1.3/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9

      $ gem install sqlite3 '1.3.9' 构建原生扩展。这可能需要一段时间... 成功安装sqlite3-1.3.9 错误:在任何存储库中都找不到有效的 gem '1.3.9' (>= 0) 已安装 1 个宝石

      即使它给出了这个错误消息,它似乎仍然可以安装

      【讨论】:

        猜你喜欢
        • 2014-11-29
        • 2014-03-25
        • 1970-01-01
        • 2014-05-29
        • 2012-07-03
        • 2017-01-24
        • 2013-10-28
        • 2019-02-26
        • 2013-12-13
        相关资源
        最近更新 更多