“rails new”命令出错(使用rbenv)

时间:2012-11-26 15:44:00

标签: ruby-on-rails ruby sqlite rbenv

我安装了rbenv,ruby和rails,但是创建新rails项目的命令导致了sqlite的异常。

rails new first_app
.
.
.
Using sass (3.2.3) 
Using sass-rails (3.2.5) 
Installing sqlite3 (1.3.6) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/alundgren/.rbenv/versions/1.9.3-p327/bin/ruby 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=/home/alundgren/.rbenv/versions/1.9.3-p327/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
    --enable-local
    --disable-local


Gem files will remain installed in /home/alundgren/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6 for inspection.
Results logged to /home/alundgren/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.

我已尝试安装sqlite gem并重新发布rbenv,但同样的错误。有没有人对如何解决这个问题有什么想法,确切的宝石名称是什么,等等?

3 个答案:

答案 0 :(得分:1)

我有同样的问题,我在ubuntu上安装了一个sqlite包:

apt-get install libsqlite3-dev

答案 1 :(得分:0)

问题是您缺少编译mysql适配器所需的头文件。该错误表明"尝试端口安装sqlite3 + universal'或者' yum install sqlite-devel'并检查您的共享库搜索路径(sqlite3共享库所在的位置)"。我会首先这样做,因为这将确保您的计算机上有正确的头文件。一旦你拥有它们,你可能必须为编译器指定文件的位置," - with-sqlite3-include"指令可能会成功。

答案 2 :(得分:0)

您的盒子上似乎没有安装 sqlite 。如果没有底层存在,宝石将不会安装。

请做:

  • macosx:brew install sqlite
  • enterprise linux:sudo yum install libsqlite3-dev
  • ubuntu:sudo apt-get install libsqlite3-dev