Search code examples
ruby-on-rails64-bitdependency-propertiestzinfo

RoR Hartl tutorial - tzinfo clash on Win 64 bit


I'm doing Hartls' tutorial on railstutorial.org

I need to run Rails 4.0.8 on my 64 bit Windows machine. This means that I have to specify the x64_mingw option on my tzinfo-data Gem in order to fix the Rails timezone bug.

  • Rails 4.0.8 needs tzinfo v 0.3.37

  • x64_mingw needs tzinfo v 1.0.0

  • Bundle fails with a 'No compatable version of tzinfo' error.

What do I do? I'm halfway through the tut and I don't want to have to switch dev machines now! I know the configuration runs okay on a 32 bit OS.

rails (= 4.0.8) x64-mingw32 depends on
  activesupport (= 4.0.8) x64-mingw32 depends on
    tzinfo (~> 0.3.37) x64-mingw32

.

tzinfo-data (>= 0) x64-mingw32 depends on
  tzinfo (>= 1.0.0) x64-mingw32

.


GEMFILE =>

source 'https://rubygems.org'
ruby '2.0.0'


gem 'rails', '4.0.8'

group :development, :test do
gem 'tzinfo', '0.3.37'
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

end

group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end

gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
gem 'sdoc', '0.3.20', require: false
end

group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end

Solution

  • You'll need to remove the dependency on tzinfo-data from your Gemfile.

    The tzinfo-data gem is only needed on Windows systems if you are using tzinfo 1.0.0 or later. Rails 4.0 uses tzinfo ~> 0.3.37, so tzinfo-data is unnecessary.

    The reason for this is that tzinfo before version 1.0.0 included all the time zone data it needed to operate (effectively bundling the tzinfo-data gem). With the release of version 1.0.0, the data was split out into a separate gem.

    If you were to upgrade to Rails 4.1 in the future on Windows, you'd need to change your Gemfile to remove the specific version dependency on tzinfo and add the tzinfo-data dependency back in. This is because Rails 4.1 requires tzinfo ~> 1.1.