问题
As stated in the title. I got
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 `<top (required
)>'
C:/.../Rakefile:4:in `require'
C:/.../Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
My rails are v4.2.2 and my ruby is v2.2 on Windows 8 (64bit). According to various SO questions I went through I might get this error due to some incompatiblities between the specific gems. Hence here's my gemfile with some options already tried out.
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
Any clues?
UPDATE
My 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, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
columnize (0.9.0)
concurrent-ruby (1.0.1)
debugger-linecache (1.2.0)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.2.3)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mime-types (3.0)
mime-types-data (~> 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, < 2.0)
railties (= 4.2.2)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 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, < 2.0)
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
sass (3.4.22)
sass-rails (5.0.2)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sdoc (0.4.0)
json (~> 1.8)
rdoc (~> 4.0, < 5.0)
slop (3.6.0)
spring (1.1.3)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
actionpack (>= 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)
回答1:
gem 'tzinfo-data'
is necessary when developing on Windows (usually it is automatically included on Gemfile
when Rails app is created on a Windows machine).
Add gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
to Gemfile
, keep tzinfo
commented out and run bundle update
.
回答2:
Thanks for the suggestions guys, it helped me a lot. The proper to solution to my problem was:
- remove gemfile.lock
- decrease tzinfo version to 1.2.1, and leave tzinfo-data as provided by user3097405.
- Then another error occured so I had to increase sqlite3 version to 1.3.11. Also it turned out I can decomment webconsle.
So, in the end the Gemfile looks like this
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
And after one more bundle install
the rake command executed properly.
回答3:
You probably have a stray reference where you're require
ing tzinfo. Does a text search find any references to it in your code?
Also make sure tzinfo
isn't in your Gemfile.lock
. Delete the Gemfile.lock and rerun bundler if it is.
来源:https://stackoverflow.com/questions/36535092/cant-execute-bundle-exec-rake-dbmigrate-due-to-tzinfo-error