sqlite3-ruby install error on Ubuntu

2020-01-25 12:23发布

I have the following error during sqlite3-ruby install:

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 is located in /usr/include/

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

doesn't work


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

Ubuntu 10.04

19条回答
混吃等死
2楼-- · 2020-01-25 12:53

Tried ALL of other solutions, none helped.

It turned out that you also need dev package for ruby itself. For me, it helped

sudo apt-get install ruby-full

It has a lot of nasty dependencies though (like emacs, wtf?), just

sudo apt-get install ruby1.8-dev

should be fine. After it's installed (and you have the sqlite and sqlite-dev packages installed)

sudo gem install sqlite3-ruby

works like a charm.

查看更多
\"骚年 ilove
3楼-- · 2020-01-25 12:53

From sqlite3-ruby gem can't find sqlite3.h on ubuntu:

You also need to install gcc itself, so in total it would be:

sudo apt-get install gcc libsqlite3-dev ruby1.8-dev
sudo gem install sqlite3

Apparently you get a wrong error pointing to a missing sqlite3.h when the actual problem is missing gcc itself.

查看更多
孤傲高冷的网名
4楼-- · 2020-01-25 12:55

This was simply enough to make it work

sudo apt-get install libsqlite3-dev

Thanks to marshluca

查看更多
太酷不给撩
5楼-- · 2020-01-25 12:55

None of the above mentioned solution worked for me, even after installing ruby2.5-dev and libsqlite3-dev. Then tried using PostgreSql instead of sqlite. That worked fine. To use PostgreSql instead of sqlite use this command when creating rails project.

rails [_VERSION_] new project_name -d postgresql

If you want to use MySql then use mysql instead of postgresql.

rails [_VERSION_] new project_name -d mysql

Else you can try without sqlite.

bundle install --without sqlite
查看更多
forever°为你锁心
6楼-- · 2020-01-25 12:57

The solution is to add -- to separate configure parameters from gem parameters.

instead of

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

try this, all on one line, make sure to include -- after the last gem parameter and before configure parameters:

sudo gem install sqlite3 --
--with-sqlite3-lib=/somewhere/local/lib
--with-sqlite3-include=/somewhere/local/include

This should get you around this error:

ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --without-sqlite3-include=/usr/include
查看更多
时光不老,我们不散
7楼-- · 2020-01-25 12:57

I agree with Danya Vershinin & EnotionZ.

If can't use apt-get:

  1. compile & install sqlite3 from sources by specifying your own "prefix" path. More information can be found in the README.
  2. Then passed this path to the sqlite3-ruby installer (don't forget the "--").
查看更多
登录 后发表回答