Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hitting TZInfo::DataSourceNotFound: No timezone data source could be found. with a fresh install of rail 4.1.0 #4

Closed
madhavankumar opened this issue Apr 11, 2014 · 18 comments
Labels

Comments

@madhavankumar
Copy link

@madhavankumar madhavankumar commented Apr 11, 2014

I get an error as below when I start the rails server

Exiting
TZInfo::DataSourceNotFound: No timezone data source could be found.

gem install tzinfo-data did not solve this.

@rafaelfranca
Copy link

@rafaelfranca rafaelfranca commented Apr 11, 2014

Even adding it to Gemfile?

@madhavankumar
Copy link
Author

@madhavankumar madhavankumar commented Apr 11, 2014

yes. Looks like others are facing this issue too. See the main issue on rails.

@philr
Copy link
Member

@philr philr commented Apr 11, 2014

Looking at your issue on the rails project I can see that you are using JRuby 1.7.11.

I've just installed a fresh JRuby 1.7.11 environment on Windows and created a new Rails 4.1.0 app to test.

When initially trying to start a Rails server or console, I encountered the same DataSourceNotFound error. This is because tzinfo-data is required on Windows.

I then added tzinfo-data to my Gemfile:

gem 'tzinfo-data'

After running bundle install, I was then able to start a Rails server and console.

Adding tzinfo-data to the Gemfile should be enough to resolve the DataSourceNotFound error. TZInfo attempts to require 'tzinfo/data' when it is first used. tzinfo/data is provided by the tzinfo-data gem.

Please could you confirm exactly what you added to your Gemfile? Could you also let me know what operating system you are using? Are you encountering the error with an empty Rails app?

@philr philr added the question label Apr 11, 2014
@danikaze
Copy link

@danikaze danikaze commented Apr 12, 2014

I'm having the same issue... I think.
I'm new to ruby & rails so I'm not quite sure...

Anyways, I'm on Windows 7 x64 and I have just installed everything (so everything is clean).
In my Gemfile there's the gem 'tzinfo-data', platforms: [:mingw, :mswin] by default.
And even if I add gem 'tzinfo' I still have the same error, which is the following:

D:\webs\rubyProject>rails server => Booting WEBrick => Rails 4.1.0 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Exiting C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:199:in 'rescue in create_default_data_source': No timezone data source could be found. To resolve this, either install TZInfo::Data (e.g. by running 'gem install tzinfo-data') or specify a zoneinfo directory using 'TZInfo ::DataSource.set(:zoneinfo, zoneinfo_path)'. (TZInfo::DataSourceNotFound) from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:196:in 'create_default_data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:62:in 'block in get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:61:in 'synchronize' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:61:in 'get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:601:in 'data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:114:in 'get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone_proxy.rb:84:in 'real_timezone' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone_proxy.rb:52:in 'period_for_utc' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone.rb:524:in 'current_period' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/object/try.rb:45:in 'public_send' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/object/try.rb:45:in 'try' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:223:in 'utc_offset' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in 'block in []' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in 'tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:396:in '[]' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/core_ext/time/zones.rb:60:in 'find_zone!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0/lib/active_support/railtie.rb:20:in 'block in class:Railtie' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in 'instance_exec' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:30:in 'run' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:55:in 'block in run_initializers' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in 'block in tsort_each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in 'block (2 levels) in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in 'each_strongly_connected_component_from' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in 'block in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in 'each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in 'each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in 'tsort_each' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/initializable.rb:54:in 'run_initializers' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/application.rb:288:in 'initialize!' from D:/webs/rubyProject/config/environment.rb:5:in '' from D:/webs/rubyProject/config.ru:3:in 'require' from D:/webs/rubyProject/config.ru:3:in 'block in ' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in 'instance_eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in 'initialize' from D:/webs/rubyProject/config.ru:in 'new' from D:/webs/rubyProject/config.ru:in '' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in 'eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in 'new_from_string' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in 'parse_file' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in 'build_app_and_options_from_config' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in 'app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:50:in 'app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in 'wrapped_app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:130:in 'log_to_stdout' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in 'start' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in 'block in server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in 'tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in 'server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in 'run_command!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in '' from bin/rails:4:in 'require' from bin/rails:4:in ''

And, by the way...

D:\webs\rubyProject>ruby -v
ruby 2.0.0p451 (2014-02-24) [x64-mingw32]


D:\webs\rubyProject>rails -v
DL is deprecated, please use Fiddle
Rails 4.1.0

@philr
Copy link
Member

@philr philr commented Apr 12, 2014

@danikaze It looks like your issue is related to 64-bit Ruby builds on Windows.

Try changing the tzinfo-data line in your Gemfile to gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin] and then running bundle update.

The :x64_mingw platform option is needed to match 64-bit Windows MinGW builds of Ruby (such as the RubyInstaller x64 builds).

@danikaze
Copy link

@danikaze danikaze commented Apr 12, 2014

nice! It seems to work now.
Thanks @philr !!

@philr
Copy link
Member

@philr philr commented Apr 12, 2014

I've created a pull request (rails/rails#14720) to get the default Rails Gemfile changed.

@fatim
Copy link

@fatim fatim commented Apr 16, 2014

I still get the same error, even after adding
gem 'tzinfo'
gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin]
and running bundle update.

My setup is:
jruby 1.7.11 (1.9.3p392) 2014-02-24 86339bb on Java HotSpot(TM) 64-Bit Server VM 1.7.0_07-b10 [Windows Server 2008 R2-amd64]

Gem.platforms
["ruby" Gem::Platform:0x802 @cpu="universal", @os="java", @Version="1.7">]

@philr
Copy link
Member

@philr philr commented Apr 16, 2014

@fatim Since you are using JRuby on Windows, you'll either need to add :jruby to the list of platforms for gem 'tzinfo-data' or remove the platforms option altogether:

gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin, :jruby]

or:

gem 'tzinfo-data'

The gem 'tzinfo-data' line you have at the moment is only including the tzinfo-data gem on native Windows Ruby builds (and not on JRuby).

The gem 'tzinfo' line is unnecessary (regardless of the platform). It is already a dependecy of rails (via activesupport).

@fatim
Copy link

@fatim fatim commented Apr 16, 2014

thanks philr !, I've tested both suggestions and they fixed the issue.

@philr
Copy link
Member

@philr philr commented Apr 21, 2014

Nothing further received from the issue opener. Assuming that this is now resolved.

@philr philr closed this Apr 21, 2014
@HatemAlSum
Copy link

@HatemAlSum HatemAlSum commented Apr 23, 2014

Just add the following Line to Gem File

gem 'tzinfo-data', platforms: [:x64_mingw,:mingw, :mswin]

@zbtzbt
Copy link

@zbtzbt zbtzbt commented Oct 13, 2014

@philr,Thank you very much, I encountered the same problem, plus: the jruby problem is solved

@zbtzbt
Copy link

@zbtzbt zbtzbt commented Oct 13, 2014

@philr,Thank you very much, I encountered the same problem, plus the " :jruby" problem is solved

@siraleem
Copy link

@siraleem siraleem commented Oct 31, 2014

My problem solved by
gem 'tzinfo-data', '~> 1.2014.9'
in gem file

@Gurmo
Copy link

@Gurmo Gurmo commented Nov 26, 2014

@siraleem Hey that fixed my error as well!

What exactly did that do?

@JalilArfaoui
Copy link

@JalilArfaoui JalilArfaoui commented Dec 9, 2014

I had the same problem and I also had it solved by
gem 'tzinfo-data', '~> 1.2014.9'
Why is that ?

@philr
Copy link
Member

@philr philr commented Dec 9, 2014

@Gurmo, @JalilArf By default, TZInfo will try and use the zoneinfo time zone data bundled with most Unix-like systems. However, if your system doesn't include this data (e.g. Windows), then you'll have to install the tzinfo-data gem instead. The tzinfo-data gem contains all the time zone data TZInfo requires packaged as a set of Ruby modules.

Please see http://stackoverflow.com/a/23023291/5981 and https://github.com/tzinfo/tzinfo/wiki/Resolving-TZInfo::DataSourceNotFound-Errors for further information.

@siraleem, @JalilArf I wouldn't recommend using the ~> 1.2014.9 version constraint you are specifying. This translates as >= 1.2014.9 and < 1.2015, so you won't get any data updates from January 2015. I recommend dropping the version constraint altogether (just put gem 'tzinfo-data' in your Gemfile).

@tzinfo tzinfo locked and limited conversation to collaborators Dec 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.