由于tzinfo错误,无法执行bundle exec rake db:migrate

正如标题中所述。 我有

C:\...>bundle exec rake db:migrate rake aborted! LoadError: cannot load such file -- tzinfo C:/.../config/application.rb:3:in `require' C:/.../config/application.rb:3:in `' C:/.../Rakefile:4:in `require' C:/.../Rakefile:4:in `' (See full trace by running task with --trace) 

我的rails是v4.2.2,我的ruby是Windows 8(64位)上的v2.2。 根据我经历的各种SO问题,由于特定gem之间的某些不兼容性,我可能会得到此错误。 因此,这是我的gemfile,已经尝试了一些选项。

 source 'https://rubygems.org' gem 'rails', '4.2.2' gem 'sass-rails', '5.0.2' gem 'uglifier', '2.5.3' gem 'coffee-rails', '4.1.0' gem 'jquery-rails', '4.0.3' gem 'turbolinks', '2.3.0' gem 'jbuilder', '2.2.3' gem 'sdoc', '0.4.0', group: :doc gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] #gem 'tzinfo', '1.2.2' group :development, :test do gem 'sqlite3', '1.3.9' gem 'byebug', '3.4.0' #gem 'web-console', '2.0.0.beta3' gem 'spring', '1.1.3' end group :production do gem 'pg', '0.17.1' gem 'rails_12factor', '0.0.2' end 

有什么线索吗?

UPDATE

我的gemfile.lock

 GEM remote: https://rubygems.org/ specs: actionmailer (4.2.2) actionpack (= 4.2.2) actionview (= 4.2.2) activejob (= 4.2.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) actionpack (4.2.2) actionview (= 4.2.2) activesupport (= 4.2.2) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.1) actionview (4.2.2) activesupport (= 4.2.2) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.1) activejob (4.2.2) activesupport (= 4.2.2) globalid (>= 0.3.0) activemodel (4.2.2) activesupport (= 4.2.2) builder (~> 3.1) activerecord (4.2.2) activemodel (= 4.2.2) activesupport (= 4.2.2) arel (~> 6.0) activesupport (4.2.2) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) builder (3.2.2) byebug (3.4.0) columnize (~> 0.8) debugger-linecache (~> 1.2) slop (~> 3.6) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, = 4.1.0) i18n (0.7.0) jbuilder (2.2.3) activesupport (>= 3.0.0,  1.2) jquery-rails (4.0.3) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, = 1.5.9) mail (2.6.4) mime-types (>= 1.16,  3.2015) mime-types-data (3.2016.0221) mini_portile2 (2.0.0) minitest (5.8.4) multi_json (1.11.2) nokogiri (1.6.7.2-x86-mingw32) mini_portile2 (~> 2.0.0.rc2) pg (0.17.1-x86-mingw32) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) rails (4.2.2) actionmailer (= 4.2.2) actionpack (= 4.2.2) actionview (= 4.2.2) activejob (= 4.2.2) activemodel (= 4.2.2) activerecord (= 4.2.2) activesupport (= 4.2.2) bundler (>= 1.3.0, = 4.2.0.alpha) rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta,  1.6.0) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails_12factor (0.0.2) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (4.2.2) actionpack (= 4.2.2) activesupport (= 4.2.2) rake (>= 0.8.7) thor (>= 0.18.1,  1.4) sass (3.4.22) sass-rails (5.0.2) railties (>= 4.0.0,  3.1) sprockets (>= 2.8, = 2.0,  1.1) sdoc (0.4.0) json (~> 1.8) rdoc (~> 4.0,  1.0) rack (> 1, = 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.9-x86-mingw32) thor (0.19.1) thread_safe (0.3.5) tilt (1.4.1) turbolinks (2.3.0) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) tzinfo-data (1.2016.3) tzinfo (>= 1.0.0) uglifier (2.5.3) execjs (>= 0.3.0) json (>= 1.8.0) PLATFORMS x86-mingw32 DEPENDENCIES byebug (= 3.4.0) coffee-rails (= 4.1.0) jbuilder (= 2.2.3) jquery-rails (= 4.0.3) pg (= 0.17.1) rails (= 4.2.2) rails_12factor (= 0.0.2) sass-rails (= 5.0.2) sdoc (= 0.4.0) spring (= 1.1.3) sqlite3 (= 1.3.9) turbolinks (= 2.3.0) tzinfo-data uglifier (= 2.5.3) 

在Windows上进行Gemfile时, Gemfile gem 'tzinfo-data' (通常在Windows机器上创建Rails应用程序时,它会自动包含在Gemfile )。

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]Gemfile ,保持tzinfo注释掉并运行bundle update

你可能有一个迷你参考,你require tzinfo。 文本搜索是否在代码中找到对它的任何引用?

还要确保tzinfo不在你的Gemfile.lock 。 删除Gemfile.lock并重新运行bundler(如果是)。

感谢你们的建议,这对我帮助很大。 解决我的问题的正确方法是:

  • 删除gemfile.lock
  • 将tzinfo版本减少到1.2.1,并保留user3097405提供的tzinfo-data。
  • 然后发生了另一个错误,所以我不得不将sqlite3版本增加到1.3.11。 事实certificate我可以解除webconsle。

所以,最终Gemfile看起来像这样

 source 'https://rubygems.org' gem 'rails', '4.2.2' gem 'sass-rails', '5.0.2' gem 'uglifier', '2.5.3' gem 'coffee-rails', '4.1.0' gem 'jquery-rails', '4.0.3' gem 'turbolinks', '2.3.0' gem 'jbuilder', '2.2.3' gem 'sdoc', '0.4.0', group: :doc gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] gem 'tzinfo', '1.2.1' group :development, :test do gem 'sqlite3', '1.3.11' gem 'byebug', '3.4.0' gem 'web-console', '2.0.0.beta3' gem 'spring', '1.1.3' end group :production do gem 'pg', '0.17.1' gem 'rails_12factor', '0.0.2' end 

bundle install一个bundle install后,正确执行rake命令。