"An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue"



我正在尝试运行捆绑安装,但是当我这样做时,我收到一条错误消息,指出"安装 sqlite3 (1.3.13( 时出错,捆绑器无法继续。我尝试运行gem install sqlite3 -v '1.3.13',但也遇到了错误。

这是我的宝石文件:

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'

这是我尝试运行捆绑安装时遇到的错误:

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 安装 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

任何帮助都值得赞赏,因为在我成功运行捆绑包安装之前我无法继续前进,并且我已经尝试了几天的研究,但无法弄清楚如何解决此问题。

更新 7/9/17:这是我更新的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', 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'

更新 7/10/17:删除 gem 'activerecord-jdbcsqlite3-adapter'、'~> 1.3'、'>= 1.3.23'后,我再次尝试捆绑安装,这次,我遇到了不同的错误:

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

有一个完美的答案。查看堆栈溢出中的文章"安装 sqlite3 (1.3.7( 时出错,Bundler 无法继续无法创建 rails 应用程序"。

我引用以下解决方案

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

gemactiverecord-jdbcsqlite3-adapter尚不兼容 Rails 5。几年前,我成功地将JRuby与Rails 4.1.3一起使用。开发 JDBC 适配器的团队在开源的基础上运行,这通常意味着他们免费工作,因此您可以得到您所得到的。

您有两种选择:

1(卸载JRuby并将Rails 5与基于MRI的解释器一起使用;或

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

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

这是运行Rails应用程序时非常普遍的问题。

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

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

指示:

第 1 步:打开您的宝石文件

第 2 步:找到它说的地方:

gem 'sqlite3'

并将其更改为:

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

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

最新更新