Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Resolving TZInfo::DataSourceNotFound Errors
You may encounter a
TZInfo::DataSourceNotFound exception with the message
No source of timezone data could be found when you use TZInfo or other libraries that depend on it (for example, Active Support and Ruby on Rails). The error indicates that TZInfo was unable to find a source of time zone data on your system. This will typically occur if you are using Windows.
The simplest way to resolve this error is to install the tzinfo-data gem, either by editing your
Gemfile or by running
gem install tzinfo-data.
On most Unix-based systems (e.g. Linux), TZInfo is able to use the system zoneinfo directory as a source of data. However, Windows doesn't include such a directory, so the tzinfo-data gem needs to be installed instead. The tzinfo-data gem contains the same zoneinfo data, but is packaged as a set of Ruby modules.
Using tzinfo-data with Bundler or Ruby on Rails
If you are using Ruby on Rails or your project uses Bundler to manage dependencies, you'll need to make sure that the tzinfo-data gem is included in your
First of all, check your Gemfile to see if there is an existing reference to tzinfo-data. If there isn't already a reference, then add the following line:
If you are using Ruby on Rails and your project was created on Windows, then you may find that there is already a line in your Gemfile like the following:
gem 'tzinfo-data', platforms: [:mingw, :mswin]
If you are using a 64-bit version of Ruby on Windows, then add
:x64_mingw to the list of platforms as follows:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
If you are using JRuby, then add
:jruby to the list of platforms:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
Alternatively, you can remove the
platforms option altogether.
After editing your
bundle update at the command line to install the tzinfo-data gem. You'll then be able to start your project.
Installing tzinfo-data manually
TZInfo attempts to load tzinfo-data by calling
require 'tzinfo/data'. If the
tzinfo-data/lib directory is on the Ruby load path, then TZInfo will be able to find and use tzinfo-data.
If you are not using a dependency management system such as Bundler, then installing the tzinfo-data gem should be sufficient to resolve the error:
gem install tzinfo-data
Manually specifying the path to a zoneinfo directory
If TZInfo fails to locate the system zoneinfo directory automatically, the path can be specified manually using