【问题标题】:Can't install sqlite无法安装sqlite
【发布时间】:2017-01-25 13:55:27
【问题描述】:

我用的是 mac。

宝石版本:2.4.5.1 Ruby 版本:ruby 2.2.3p173(2015-08-18 修订版 51636)[x86_64-darwin15] 宝石文件:

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

我花了大约 3 个小时寻找解决方案,但没有运气。

我阅读了 Michael Hartl 的“Ruby on Rails 教程”,第 46 页。

第一个错误导致另一个错误,然后导致另一个错误......

从这个命令开始:

bundle install --without production

导致这个错误:

    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.

然后,由于最后一句话“确保gem install sqlite3 -v '1.3.5'在捆绑之前成功。 ",我运行那个命令:

gem install sqlite3 -v '1.3.5'

并得到这个我不知道该怎么办的错误:

    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$ 

我尝试了this 线程上的建议,但所有建议都返回“找不到命令”。

按照this 线程中的建议,我也尝试运行gem install sqlite3-ruby,但没有成功。

我尝试按照this 线程中的建议运行gem sources --add http://rubygems.org/,以防失败与HTTPS 或HTTP 有关,但不起作用。

有什么建议吗?

谢谢! 乔纳斯

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 sqlite


    【解决方案1】:

    请尝试如下安装:

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

    【讨论】:

      【解决方案2】:

      试试

      bundle update sqlite3
      

      我在这里看到了

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

      【讨论】:

        【解决方案3】:

        你的系统中安装了 SQLite3 吗?

        如果您使用的是 MacPorts:

        sudo port install sqlite3

        或酿造:

        brew install sqlite3

        【讨论】:

          猜你喜欢
          • 2019-09-09
          • 1970-01-01
          • 2017-06-19
          • 1970-01-01
          • 2011-04-24
          • 2017-07-02
          • 1970-01-01
          • 1970-01-01
          • 2013-09-19
          相关资源
          最近更新 更多