【问题标题】:tzinfo-data issue when starting new rails project启动新 Rails 项目时出现 tzinfo-data 问题
【发布时间】:2019-06-09 01:25:16
【问题描述】:

在启动新的 Rails 项目时遇到 TZInfo::DataSourceNotFound 问题,即使进入 Gemfile

当我开始一个新的 Rails 项目时,遇到以下错误:
C:>rails new demo2 创建
创建 README.md
创建 Rakefile
创建 .ruby 版本
创建 config.ru
创建 .gitignore
创建 Gemfile
从“。”运行 git init
创建 package.json
创建应用
创建 app/assets/config/manifest.js
创建应用程序/资产/javascripts/application.js
创建应用程序/资产/javascripts/cable.js
创建 app/assets/stylesheets/application.css
创建 app/channels/application_cable/channel.rb
创建 app/channels/application_cable/connection.rb
创建应用程序/控制器/application_controller.rb
创建 app/helpers/application_helper.rb
创建 app/jobs/application_job.rb
创建 app/mailers/application_mailer.rb
创建 app/models/application_record.rb
创建 app/views/layouts/application.html.erb
创建应用程序/视图/布局/mailer.html.erb
创建应用程序/视图/布局/mailer.text.erb
创建应用程序/资产/图像/.keep
创建应用程序/资产/javascripts/频道
创建应用程序/资产/javascripts/channels/.keep
创建应用程序/控制器/关注/.keep
创建应用程序/模型/关注/.keep
创建垃圾箱
创建 bin/bundle
创建 bin/rails
创建 bin/rake
创建 bin/设置
创建 bin/更新
创建仓/纱线
创建配置
创建 config/routes.rb
创建 config/application.rb
创建 config/environment.rb
创建 config/cable.yml
创建 config/puma.rb
创建 config/storage.yml
创建配置/环境
创建 config/environments/development.rb
创建 config/environments/production.rb
创建 config/environments/test.rb
创建配置/初始化程序
创建 config/initializers/application_controller_renderer.rb
创建 config/initializers/assets.rb
创建 config/initializers/backtrace_silencers.rb
创建 config/initializers/content_security_policy.rb
创建 config/initializers/cookies_serializer.rb
创建 config/initializers/cors.rb
创建 config/initializers/filter_parameter_logging.rb
创建 config/initializers/inflections.rb
创建 config/initializers/mime_types.rb
创建 config/initializers/new_framework_defaults_5_2.rb
创建 config/initializers/wrap_parameters.rb
创建配置/语言环境
创建 config/locales/en.yml
创建配置/master.key
附加 .gitignore
创建 config/boot.rb
创建 config/database.yml
创建数据库
创建 db/seeds.rb
创建库
创建库/任务
创建 lib/tasks/.keep
创建库/资产
创建 lib/assets/.keep
创建日志
创建日志/.keep
创建公共
创建 public/404.html
创建 public/422.html
创建 public/500.html
创建 public/apple-touch-icon-precomposed.png
创建 public/apple-touch-icon.png
创建 public/favicon.ico
创建 public/robots.txt
创建 tmp
创建 tmp/.keep
创建 tmp/缓存
创建 tmp/缓存/资产
创建供应商
创建供应商/.keep
创建测试/夹具
创建测试/夹具/.keep
创建测试/夹具/文件
创建测试/夹具/文件/.keep
创建测试/控制器
创建测试/控制器/.keep
创建测试/邮件
创建 test/mailers/.keep
创建测试/模型
创建测试/模型/.keep
创建测试/助手
创建测试/助手/.keep
创建测试/集成
创建测试/集成/.keep
创建 test/test_helper.rb
创建测试/系统
创建测试/系统/.keep
创建 test/application_system_test_case.rb
创建存储
创建存储/.keep
创建 tmp/存储
创建 tmp/storage/.keep
删除 config/initializers/cors.rb
删除 config/initializers/new_framework_defaults_5_2.rb
运行捆绑安装
依赖 tzinfo-data (>= 0) 将不会被 Bundler 安装的任何平台使用。 Bundler 正在为 ruby​​ 安装,但依赖项仅适用于 x86-mingw32、x86-mswin32、x64-mingw32、java。要将这些平台添加到包中,请运行 bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java。
正在从 https://rubygems.org/ 获取 gem 元数据......
https://rubygems.org/ 获取 gem 元数据。
解决依赖关系...
无法在集合中找到满足 tzinfo-data (>= 0) 的规范。也许锁定文件已损坏?

我按照上面的建议进行操作:
捆绑锁 --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java

然后:
捆绑安装

一切似乎都很好。

当我尝试启动 Rails 服务器时,遇到以下错误:
C:\demo2>rails 服务器
=> Booting Puma
=> Rails 5.2.2 application starting in development
=> Run rails server -h for more startup options
退出
回溯(最近一次通话最后一次):
57:来自 bin/rails:4:in ' 56:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in require'
55:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in load_dependency' 54:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 块中的 require'
53:来自 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:来自 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:来自 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:来自 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:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in '
47:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:46:in 调用 46:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/command/base.rb:65:in perform'
45:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch 44:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command'
43:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run 42:来自 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:来自 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:来自 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:来自 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:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:354:in Wrapped_app' 36:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/server.rb:219:in app' 34:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:40:in parse_file'
32:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in new_from_string'
31:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:49:in eval' 30:来自 config.ru:in' 29:来自 config.ru:in new' 28:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in 初始化'
27:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in instance_eval' 26:来自 config.ru:3:in 块中的 '
25:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in require'
23:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in load_dependency' 22:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in 块中的 require'
21:来自 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:来自 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:来自 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:来自 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:来自 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:来自 C:/demo2/config/environment.rb:5:in '
15:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:361:in 初始化! 14:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in run_initializers'
13:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:205:in tsort_each' 12:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:226:in tsort_each'
11:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in each_strongly_connected_component' 10:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in call'
9:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:347:in each' 8:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:349:in block in each_strongly_connected_component'
7:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:431:in each_strongly_connected_component_from' 6:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component'
5:来自 C:/Ruby25-x64/lib/ruby/2.5.0/tsort.rb:228:in block in tsort_each' 4:来自 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:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in run' 2:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in instance_exec'
1:来自 C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/railtie.rb:36:in 块中的' C:/Ruby25-x64/lib /ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/railtie.rb:39:在类中的块中救援:Railtie':tzinfo-data不存在。请将 gem 'tzinfo-data' 添加到您的 Gemfile 并运行 bundle install (TZInfo::DataSourceNotFound)

已检查 Gemfile,条目在那里
gem 'tzinfo-data',平台:[:mingw, :mswin, :x64_mingw, :jruby]

环境:
Windows 10 64 位
ruby 2.5.3p105(2018-10-18 修订版 65156)[x64-mingw32]
导轨 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'
@ 987654345@
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]

【问题讨论】:

  • "一切似乎都很好。"好吧....那有什么问题呢?
  • 试图弄清楚是什么阻止了我的帖子。已编辑完成问题。
  • 发布您的 Gemfile。
  • Gemfile 已发布。

标签: ruby-on-rails


【解决方案1】:

设法解决了问题。

步骤: 1. 在 Gemfile 中删除 ", platforms: [:mingw, :mswin, :x64_mingw, :jruby]" 为 "gem 'tzinfo-data', 平台: [:mingw, :mswin, :x64_mingw, :jruby]"
2. 运行 gem uninstall tzinfo-data
3.运行捆绑安装

重新安装 tzinfo-data 后,rails 服务器就可以启动了。

感谢您提供建议和努力帮助我解决此问题。

【讨论】:

  • 感谢您发布解决方案! :)
  • 非常感谢
  • 非常感谢!在 Windows 上的 Rails 中真的有这么多魔法
【解决方案2】:

这不是一个真正的解决方案,但是当我尝试安装它时,在 Windows 上使用 rails 让我非常抓狂。 如果您使用的是 Windows,请尝试 AWS C9 或其他云开发平台,它会改变生活...

【讨论】:

    【解决方案3】:

    使用

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

    在您的 gemfile 中,根据 tzinfo-data gem page

    不要忘记在它之后运行捆绑安装

    【讨论】:

      猜你喜欢
      • 2020-09-26
      • 1970-01-01
      • 1970-01-01
      • 2016-11-20
      • 2018-07-31
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 2012-07-17
      相关资源
      最近更新 更多