0
votes

Encountered TZInfo::DataSourceNotFound issue when starting new rails project even though entry in Gemfile

When I start a new rails project, below error encountered:
C:>rails new demo2 create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
create package.json
create app
create app/assets/config/manifest.js
create app/assets/javascripts/application.js
create app/assets/javascripts/cable.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images/.keep
create app/assets/javascripts/channels
create app/assets/javascripts/channels/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create bin/update
create bin/yarn
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/cable.yml
create config/puma.rb
create config/storage.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/application_controller_renderer.rb
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/content_security_policy.rb
create config/initializers/cookies_serializer.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_framework_defaults_5_2.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/master.key
append .gitignore
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create tmp
create tmp/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create test/fixtures
create test/fixtures/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create storage
create storage/.keep
create tmp/storage
create tmp/storage/.keep
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_5_2.rb
run bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Unable to find a spec satisfying tzinfo-data (>= 0) in the set. Perhaps the lockfile is corrupted?

I follow as suggested above:
bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java

Then:
bundle install

All seems well.

When I try to start the rails server, encountered below error:
C:\demo2>rails server
=> Booting Puma
=> Rails 5.2.2 application starting in development
=> Run rails server -h for more startup options
Exiting
Traceback (most recent call last):
57: from bin/rails:4:in ' 56: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in require'
55: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in load_dependency' 54: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in block in require'
53: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in require' 52: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in require_with_bootsnap_lfi'
51: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in register'
50: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in block in require_with_bootsnap_lfi'
49: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in require' 48: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in '
47: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:46:in invoke 46: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/command/base.rb:65:in perform'
45: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch 44: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command'
43: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run 42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in perform'
41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in tap' 40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147:in block in perform'
39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:51:in start' 38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:89:in log_to_stdout'
37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:354:in wrapped_app' 36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27:in app'
35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:219:in app' 34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:319:in build_app_and_options_from_config'
33: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in parse_file'
32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in new_from_string'
31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in eval' 30: from config.ru:in' 29: from config.ru:in new' 28: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in initialize'
27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in instance_eval' 26: from config.ru:3:in block in '
25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in require_relative' 24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in require'
23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in load_dependency' 22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in block in require'
21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in require'
20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in require_with_bootsnap_lfi'
19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in register'
18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in block in require_with_bootsnap_lfi'
17: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in require' 16: from C:/demo2/config/environment.rb:5:in '
15: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:361:in initialize!' 14: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in run_initializers'
13: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:205:in tsort_each' 12: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:226:in tsort_each'
11: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in each_strongly_connected_component' 10: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in call'
9: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in each' 8: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:349:in block in each_strongly_connected_component'
7: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:431:in each_strongly_connected_component_from' 6: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component'
5: from C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:228:in block in tsort_each' 4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in block in run_initializers'
3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in run' 2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in instance_exec'
1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/railtie.rb:36:in block in ' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/railtie.rb:39:in rescue in block in class:Railtie': tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install (TZInfo::DataSourceNotFound)

Have checked the Gemfile, entry is there
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Environment:
Windows 10 64-bit
ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]
Rails 5.2.2

Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'duktape'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
end

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

3
"All seems well." okay.... whats the question then?Lenin Raj Rajasekaran
Was trying to figure out what was stopping my post. Have edited to complete the issue.Donald
post your Gemfile.Lenin Raj Rajasekaran
Gemfile posted.Donald

3 Answers

1
votes

It's not a real solution, but using rails on windows makes me so crazy when i tried to install it. Try AWS C9 or another cloud development platform if you are on windows, it changes life...

1
votes

Managed to resolved the issue.

Steps: 1. Remove ", platforms: [:mingw, :mswin, :x64_mingw, :jruby]" in Gemfile for "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]"
2. Run gem uninstall tzinfo-data
3. Run bundle install

After reinstalling back tzinfo-data, the rails server is able to start up.

Thank you for suggestions and effort to try and help me to resolve this issue.

0
votes

Use

gem 'tzinfo-data', '~> 1.2019', '>= 1.2019.2'

in your gemfile, as per tzinfo-data gem page

Don't forget to run bundle install after it