3

在检查我的系统是否满足最低要求后,我开始检查版本是否合适: 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
4

4 回答 4

9

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

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

在那之后,rails server对我来说效果很好。我在本地主机上欢迎我。

于 2013-12-04T18:37:07.163 回答
1

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

于 2013-09-26T15:02:21.083 回答
1

对我来说,我得到了错误(在 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 工作人员 7 月 31 日 33 日 15:48 /usr/local/lib/libgmp.a -> ../Cellar/gmp/6.0.0a/lib/libgmp. 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 工作人员 39 Jul 31 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 个 gem

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

于 2014-10-20T16:52:12.733 回答
0

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

于 2013-10-16T19:11:29.383 回答