【问题标题】:"An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue"“安装 sqlite3 (1.3.13) 时出错,Bundler 无法继续”
【发布时间】:2017-07-07 23:19:50
【问题描述】:

我正在尝试运行 bundle install,但是当我这样做时,我收到一条错误消息,提示“安装 sqlite3 (1.3.13) 时发生错误,并且 Bundler 无法继续。”我尝试运行 gem install sqlite3 -v '1.3.13',但也遇到了错误。

这是我的 Gemfile:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Use sqlite3 as the database for Active Record
    gem 'sqlite3'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

group :production do 
    gem 'pg' 
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'jquery-rails'

gem 'devise'

这是我尝试运行 bundle install 时遇到的错误:

Kelly@LAPTOP /c/Sites/my_app (master)
$ bundle install
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 12.0.0
Using concurrent-ruby 1.0.5 (java)
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6 (java)
Using builder 3.2.3
Using erubi 1.6.0
Using nokogiri 1.8.0 (java)
Using rack 2.0.3
Using nio4r 2.1.0 (java)
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using bundler 1.15.1
Using method_source 0.8.2
Using thor 0.19.4
Using puma 3.9.1 (java)
Using sass 3.4.24
Using tilt 2.0.7
Using execjs 2.7.0
Using coffee-script-source 1.12.2
Using turbolinks-source 5.0.3
Using multi_json 1.12.1
Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Fetching bindex 0.5.0
Installing bindex 0.5.0 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Using bcrypt 3.1.11 (java)
Using orm_adapter 0.5.0
Using tzinfo 1.2.3
Using loofah 2.0.3
Using rack-test 0.6.3
Using sprockets 3.7.1
Using warden 1.2.7
Using websocket-driver 0.6.5 (java)
Using mime-types 3.1
Using uglifier 3.2.0
Using coffee-script 2.4.1
Using turbolinks 5.0.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13/ext/sqlite3
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170707-17112-s04bux.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an
executable file.
You have to install development tools first.

                 try_do at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:456
                try_cpp at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:587
   block in find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1144
  block in checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:942
      block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
      block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
               postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:346
           checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:941
            find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1143
                 <main> at extconf.rb:50
*** 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=C:/jruby-9.1.8.0/bin/jruby
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13 for inspection.
Results logged to
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/gem_make.out

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

In Gemfile:
  sqlite3

这是我尝试运行 gem install sqlite -v '1.3.13' 时遇到的错误:

Kelly@LAPTOP /c/Sites/my_app (master)
$ gem install sqlite3 -v '1.3.13'
Building native extensions.  This could take a while...
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    current directory: C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13/ext/sqlite3
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170707-17048-ojikan.rb extconf.rb
checking for sqlite3.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

                 try_do at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:456
                try_cpp at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:587
   block in find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1144
  block in checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:942
      block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
      block in postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:350
                   open at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:320
               postpone at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:346
           checking_for at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:941
            find_header at C:/jruby-9.1.8.0/lib/ruby/stdlib/mkmf.rb:1143
                 <main> at extconf.rb:50
*** 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=C:/jruby-9.1.8.0/bin/jruby
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/sqlite3-1.3.13 for inspection.
Results logged to C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/gem_make.out

感谢任何帮助,因为在我成功运行捆绑安装之前我无法继续前进,并且我已经尝试研究了几天但无法弄清楚如何解决这个问题。

2017 年 7 月 9 日更新:这是我更新后的 Gemfile,我仍然无法运行 bundle install 或 bundle update:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Use sqlite3 as the database for Active Record
    gem 'sqlite3', platform: :ruby
    gem 'jdbc-sqlite3', platform: :jruby
    gem 'activerecord-jdbc-adapter', platform: :jruby
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

group :production do 
    gem 'pg' 
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'jquery-rails'

gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3', '>= 1.3.23'

2017 年 7 月 10 日更新:删除 gem 'activerecord-jdbcsqlite3-adapter', '~> 1.3', '>= 1.3.23'后,我再次尝试 bundle install,这一次,我得到了一个不同的错误:

Kelly@LAPTOP /c/Sites/my_app (master)
$ bundle install
The dependency sqlite3 (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for x86-mingw32, java but the dependency is only for ruby. To add those platforms to the bundle, run `bundle lock --add-platform ruby`.
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 12.0.0
Using concurrent-ruby 1.0.5 (java)
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6 (java)
Using builder 3.2.3
Using erubi 1.6.0
Using nokogiri 1.8.0 (java)
Using rack 2.0.3
Using nio4r 2.1.0 (java)
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using bundler 1.15.1
Using method_source 0.8.2
Using thor 0.19.4
Using puma 3.9.1 (java)
Using sass 3.4.24
Using tilt 2.0.7
Using execjs 2.7.0
Using coffee-script-source 1.12.2
Using turbolinks-source 5.0.3
Using multi_json 1.12.1
Using jdbc-sqlite3 3.15.1
Fetching bindex 0.5.0
Installing bindex 0.5.0 with native extensions
C:/jruby-9.1.8.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:56: warning: Tempfile#unlink or delete called on open file; ignoring
Using tzinfo 1.2.3
Using loofah 2.0.3
Using rack-test 0.6.3
Using sprockets 3.7.1
Using websocket-driver 0.6.5 (java)
Using mime-types 3.1
Using uglifier 3.2.0
Using coffee-script 2.4.1
Using turbolinks 5.0.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
C:/jruby-9.1.8.0/bin/jruby.exe -r ./siteconf20170710-21728-1asiecp.rb extconf.rb

current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.

current directory:
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0/ext/bindex
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.

make failed, exit code 1

Gem files will remain installed in
C:/jruby-9.1.8.0/lib/ruby/gems/shared/gems/bindex-0.5.0 for inspection.
Results logged to
C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/bindex-0.5.0/gem_make.out

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

In Gemfile:
  web-console was resolved to 3.5.1, which depends on
    bindex

【问题讨论】:

  • 你正在运行gem installsqlite3 -v '1.1.13',需要一个空格gem install sqlite3 -v '1.1.13'
  • 啊,是的。我刚刚添加了一个空格,但仍然出现错误。当我添加空间并尝试再次运行它时,我更新了我的问题以显示错误。
  • RuntimeError: The compiler failed to generate an executable file. You have to install development tools first. ---- To see why this extension failed to compile, please check the mkmf.log which can be found here: C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/sqlite3-1.3.13/mkmf.log 可能在这两者之间你可以找出解决方案
  • 我找不到 C:/jruby-9.1.8.0/lib/ruby/gems/shared/extensions/universal-j‌​ava-1.8/2.3.0/sqlite‌​3-1.3。 13/mkmf.log 在我的 Windows 资源管理器中,你知道我需要安装哪个开发工具吗?
  • @kellya 您知道,如果您将评论指向特定用户,就像我在这里所做的那样,该用户会在其导航栏中收到通知。当您使用更多信息更新问题时,您不必依赖该用户记住返回您的问题。不发送通知意味着您将不得不依赖我的注意力范围,即......哦,看起来很闪亮!

标签: ruby-on-rails sqlite rubygems bundle-install


【解决方案1】:

有一个完美的答案。查看stackoverflow中的文章“安装sqlite3(1.3.7)时发生错误,Bundler无法继续无法创建rails应用程序”。

我引用以下解决方案

它失败了,因为你缺少一个依赖。您可以通过运行 sudo apt-get install libsqlite3-dev

来获取它

【讨论】:

  • Windows 10 怎么样?
【解决方案2】:

gem activerecord-jdbcsqlite3-adapter 还不兼容 Rails 5。几年前,我能够成功地将 JRuby 与 Rails 4.1.3 一起使用。致力于 JDBC 适配器的团队在开源基础上运作,这通常意味着他们免费工作,so you get what you get

你有两个选择:

1) 卸载 JRuby 并使用带有基于 MRI 的解释器的 Rails 5;或

2) 将 JRuby 与旧版本的 Rails 一起使用,例如 4.2.9 或更低版本。

我的建议是坚持使用选项 1,因为您根本不需要做任何特别的事情——MRI 是普通的 Ruby 解释器。您也从未解释过选择 JRuby 的原因,这让我有点怀疑XY Problem。如果您选择选项 2,请查看您选择 JRuby 的原因,并确保您知道自己在做什么以及为什么这样做。

【讨论】:

  • 感谢您的回复!我在 Gemfile 的什么位置放: gem 'sqlite3', platform: :ruby gem 'jdbc-sqlite3', platform: :jruby gem 'activerecord-jdbc-adapter', platform: :jruby 我怎么知道我的数据库名称是什么?最后,在尝试运行 rails server 时出现错误:在 Gemfile 中列出的任何 gem 源中找不到 gem 'activerecord-jdbcsqlite3-adapter (>= 1.3.23, ~> 1.3) x86-mingw32'。运行 bundle install 以安装缺少的 gem。尝试运行捆绑安装,但它要求我运行捆绑更新,我这样做了,但随后它要求我运行捆绑安装。
  • 找不到 gem,因为您没有更改 gemfile。将该 sn-p 包含在 gemfile 的开发块中,之后您应该运行 bundle install。另外,请发布您的 gemfile 的更新,因为我怀疑您在原始发布和现在之间更新了它,但您没有说明它是否或如何更改。
  • @kellya Could not find gem 'activerecord-jdbcsqlite3-adapter (&gt;= 1.3.23, ~&gt; 1.3) x86-mingw32' 是由您的 gemfile 中的行引起的 gem 'activerecord-jdbcsqlite3-adapter', '~&gt; 1.3', '&gt;= 1.3.23'. 摆脱它。
  • 我认为我们正在取得一些进展,但我还没有完全做到。我删除了 Gemfile 中的最后一行并尝试再次运行 bundle install ,但它仍然没有工作,但这次它给了我一个不同的错误(见上文)。我尝试根据错误消息请求运行 gem install bindex -v '0.5.0' ,但这也不起作用。 @MarsAtomic
  • @kellya 这是您的最终裁决。没有BS:这些家伙真的很支持。我的建议是停止让你自己(以及我自己)的生活变得困难,并坚持使用香草安装(即没有 JRuby),直到你知道自己在做什么。
【解决方案3】:

这是运行 Rails 应用时非常常见的问题。

答案在这个链接:https://github.com/sparklemotion/sqlite3-ruby/issues/224

或这个 Youtube 视频:https://www.youtube.com/watch?v=G-B_KUFNkQQ&t=556s

说明:

第 1 步:打开您的 Gemfile

第 2 步:找到它说的位置:

gem 'sqlite3'

并将其更改为:

gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"

(如果服务器仍未运行,请运行“捆绑安装”。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-14
    • 2013-03-11
    • 2013-07-21
    • 2022-01-20
    • 2017-02-09
    • 2018-09-08
    • 2020-01-16
    相关资源
    最近更新 更多