简体   繁体   中英

Can't install sqlite

I use mac.

Gem version: 2.4.5.1 Ruby version: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15] Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.3'

group :development do
    gem 'sqlite3', '1.3.5'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.1'

group :production do
    gem 'pg', '0.12.2'
end

I spent about 3 hours searching a solution, without luck.

I read 'Ruby on Rails Tutorial' by Michael Hartl, on page 46.

First one error that leads to another, that leads to another...

It starts with this command:

bundle install --without production

That results in this error:

    Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 11.2.2
Using i18n 0.7.0
Using multi_json 1.12.1
Using builder 3.0.4 (was 3.2.2)
Using erubis 2.7.0
Using journey 1.0.4
Using rack 1.4.7 (was 2.0.1)
Using hike 1.2.3
Using tilt 1.4.1 (was 2.0.5)
Using mime-types 1.25.1 (was 3.1)
Using polyglot 0.3.5
Using arel 3.0.3 (was 7.1.2)
Using tzinfo 0.3.51 (was 1.2.2)
Using bundler 1.13.1
Using coffee-script-source 1.10.0
Using execjs 2.7.0
Using json 1.8.3
Using thor 0.14.6 (was 0.19.1)
Using sass 3.4.22
Installing sqlite3 1.3.5 (was 1.3.11) with native extensions
Using activesupport 3.2.3 (was 5.0.0.1)
Using rack-cache 1.6.1
Using rack-test 0.6.3
Using rack-ssl 1.3.4
Using sprockets 2.1.4 (was 3.7.0)
Using treetop 1.4.15
Using coffee-script 2.4.1
Using uglifier 1.2.3 (was 3.0.2)
Using rdoc 3.12.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/Money/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20160917-4100-9i5b1f.rb
extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling backup.c
compiling database.c
compiling exception.c
compiling sqlite3.c
compiling statement.c
statement.c:258:11: warning: implicit declaration of function 'RBIGNUM' is invalid in
C99 [-Wimplicit-function-declaration]
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
          ^
./sqlite3_ruby.h:16:24: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
                       ^
statement.c:258:11: error: member reference type 'int' is not a pointer
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
          ^~~~~~~~~~~~~~~~~~
./sqlite3_ruby.h:16:36: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
                       ~~~~~~~~~~  ^
statement.c:258:32: error: use of undeclared identifier 'SIZEOF_BDIGITS'
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
                               ^
1 warning and 2 errors generated.
make: *** [statement.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/Money/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5 for
inspection.
Results logged to
/Users/Money/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/sqlite3-1.3.5/gem_make.out

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

Then, because of the last phrase " Make sure that gem install sqlite3 -v '1.3.5' succeeds before bundling. ", I run that command:

gem install sqlite3 -v '1.3.5'

And get this error which I have no clue what to do about:

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

    /Users/Money/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20160917-4314-20lcl4.rb extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling backup.c
compiling database.c
compiling exception.c
compiling sqlite3.c
compiling statement.c
statement.c:258:11: warning: implicit declaration of function 'RBIGNUM' is invalid in C99 [-Wimplicit-function-declaration]
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
          ^
./sqlite3_ruby.h:16:24: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
                       ^
statement.c:258:11: error: member reference type 'int' is not a pointer
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
          ^~~~~~~~~~~~~~~~~~
./sqlite3_ruby.h:16:36: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
                       ~~~~~~~~~~  ^
statement.c:258:32: error: use of undeclared identifier 'SIZEOF_BDIGITS'
      if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
                               ^
1 warning and 2 errors generated.
make: *** [statement.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/Money/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.5 for inspection.
Results logged to /Users/Money/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/sqlite3-1.3.5/gem_make.out
Jonass-MBP:demo_app Money$ 

I tried the suggestions on this thread, but all suggestions return with "Command not found".

I tried to run gem install sqlite3-ruby as well, as suggested in this thread, didn't work.

I tried to run gem sources --add http://rubygems.org/ , as suggested in this thread, in case the failure had something to do with HTTPS or HTTP, didn't work.

Any suggestions?

Thank you! Jonas

Please do try to install it as follows :

gem install sqlite3 -v '1.3.5' -- --srcdir=/usr/local/mysql/include

try

bundle update sqlite3

I saw it here

http://stackoverflow.com/questions/34151296/cannot-install-sqlite3-gem

Did you have SQLite3 installed in system?

If you're using MacPorts:

sudo port install sqlite3

or Brew:

brew install sqlite3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM