sqlite3-ruby安装过程中出现以下错误:

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

/usr/bin/ruby1.8 extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel'
*** 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.8
    --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 /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.1/ext/sqlite3/gem_make.out

Sqlite3.h位于/usr/include/中

sudo gem install sqlite3-ruby --without-sqlite3-include=/usr/include

不工作


ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --without-sqlite3-include=/usr/include

Ubuntu 10.04


当前回答

不是——without-sqlite3-include=/usr/include,而是——with-sqlite3-include=/usr/include。

其他回答

上面提到的解决方案都不适合我,即使在安装了ruby2.5-dev和libsqlite3-dev之后。然后尝试使用PostgreSql代替sqlite。效果很好。在创建rails项目时使用PostgreSql而不是sqlite使用此命令。

rails [_VERSION_] new project_name -d postgresql

如果你想使用MySql,请使用MySql而不是postgresql。

rails [_VERSION_] new project_name -d mysql

否则,您可以尝试不使用sqlite。

bundle install --without sqlite

我也遇到了同样的问题,下面的方法对我很有效:

将sqlite3编译为静态库,安装在主目录中的某个位置,然后为gem安装过程提供该选项。

进入下载页面并获取源代码。目前最新的版本是http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz

Tar -xf文件或做任何你通常做解压;输入目录

./configure——disable-shared——enable-static——prefix=/some/path/in/my/home

编译,安装,当你安装gem…

Gem install sqlite3-ruby -- --with-sqlite3-dir=/some/path/in/my/home

我刚刚降级为sqlite3-ruby '1.2.2'

不是——without-sqlite3-include=/usr/include,而是——with-sqlite3-include=/usr/include。

这就是我所做的:

wget http://www.sqlite.org/sqlite-amalgamation-3.7.2.tar.gz
tar xzf sqlite-amalgamation-3.7.2.tar.gz
cd sqlite-3.7.2/

./configure
make
make install

gem install rails sqlite3-ruby

来源:http://cuasan.wordpress.com/2010/10/13/rails-3-on-debian-with-sqlite-3/