繁体   English   中英

rails 服务器未运行退出

[英]rails server not running exiting

这是我在运行rails server时得到的output。 我是ROR的新手,版本是3.1.0。 任何帮助,将不胜感激

我在 windows 10 设置中运行它。 如果您需要更多详细信息,请告诉我我可以提供。 我的专业是 Php/ Asp.net 开发人员,主要从事 MVC laravel、CodeIgniter 和 Yii2 等框架的工作

  Exiting
        C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:159:in `rescue in 

create_default_data_source': tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install (TZInfo::DataSourceNotFound)     
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:156:in `create_default_data_source' 
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:55:in `block in get'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `synchronize'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `get'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.2.2/lib/active_support/railtie.rb:88:in `block in <class:Railtie>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `run'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `call'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'       
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/application.rb:372:in `initialize!'
            from C:/xampp/htdocs/simple-app/config/environment.rb:5:in `<main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:42:in `require_relative'
            from config.ru:3:in `block in <main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'   
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:36:in `start' 
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:143:in `block 
    in perform'
            from <internal:kernel>:90:in `tap'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:134:in `perform'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command/base.rb:87:in `perform'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command.rb:48:in `invoke'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands.rb:18:in `<main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from bin/rails:4:in `<main>'
    C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_sources/zoneinfo_data_source.rb:232:in `initialize': None of the paths included in TZInfo::DataSources::ZoneinfoDataSource.search_path are valid zoneinfo directories. (TZInfo::DataSources::ZoneinfoDirectoryNotFound)
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:157:in `new'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:157:in `create_default_data_source' 
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:55:in `block in get'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `synchronize'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `get'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.2.2/lib/active_support/railtie.rb:88:in `block in <class:Railtie>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:32:in `run'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `call'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
            from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'       
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/application.rb:372:in `initialize!'
            from C:/xampp/htdocs/simple-app/config/environment.rb:5:in `<main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:42:in `require_relative'
            from config.ru:3:in `block in <main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:349:in `build_app_and_options_from_config'   
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:249:in `app'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:422:in `wrapped_app'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:36:in `start' 
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:143:in `block 
    in perform'
            from <internal:kernel>:90:in `tap'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands/server/server_command.rb:134:in `perform'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command/base.rb:87:in `perform'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/command.rb:48:in `invoke'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.2.2/lib/rails/commands.rb:18:in `<main>'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.10.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
            from bin/rails:4:in `<main>'

我已经运行了 bundle install 和 bundle update 我的 Gemfile 看起来像这样

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

  ruby "3.1.0"

  # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
  gem "rails", "~> 7.0.2", ">= 7.0.2.2"

  # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
  gem "sprockets-rails"

  # Use sqlite3 as the database for Active Record
  gem "sqlite3", "~> 1.4"

  # Use the Puma web server [https://github.com/puma/puma]
  gem "puma", "~> 5.0"

  # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
  gem "importmap-rails"

  # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
  gem "turbo-rails"

  # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
  gem "stimulus-rails"

  # Build JSON APIs with ease [https://github.com/rails/jbuilder]
  gem "jbuilder"

  # Use Redis adapter to run Action Cable in production
  # gem "redis", "~> 4.0"

  # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
  # gem "kredis"

  # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
  # gem "bcrypt", "~> 3.1.7"

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

  # Reduces boot times through caching; required in config/boot.rb
  gem "bootsnap", require: false

  # Use Sass to process CSS
  # gem "sassc-rails"

  # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
  # gem "image_processing", "~> 1.2"

  group :development, :test do
    # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
    gem "debug", platforms: %i[ mri mingw x64_mingw ]
  end

  group :development do
    # Use console on exceptions pages [https://github.com/rails/web-console]
    gem "web-console"

    # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
    # gem "rack-mini-profiler"

    # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
    # gem "spring"
  end

  group :test do
    # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
    gem "capybara"
    gem "selenium-webdriver"
    gem "webdrivers"
  end

更改(在 Gemfile 中 - 此行当前在 Windows 中默认添加):

gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

到:
gem 'tzinfo-data'
然后运行命令:
bundle update
这可能会解决你的问题

--为什么会出现这个错误?--
我是 Ruby on Rails 的新手 - RoR
我正在使用:
ruby 3.1.1p18(2022-02-18 修订版 53f5fc4236)[x64-mingw-ucrt]
轨道 7.0.2.2
宝石 3.3.7
据我在谷歌上搜索所知,RoR 目前在 windows x64-mingw-ucrt 上不起作用,您可以通过命令检查您的:
C:\xxx\xxx> ruby -v
或者:
C:\xxx\xxx> bundle platform
output:
您的平台是:x64-mingw-ucrt

1)gem“tzinfo-data”,平台:%i[mingw mswin x64_mingw jruby]删除,平台:%i[mingw mswin x64_mingw jruby]

-> # Windows 不包含 zoneinfo 文件,因此捆绑 tzinfo-data gem gem“tzinfo-data”

2) 卸载 tzinfo-data -> $ gem uninstall tzinfo-data

3)-> $ 捆绑安装

4) 安装 tzinfo-data -> $ gem install tzinfo-data

注意; 如果你还没有安装 tzinfo-data 来执行卸载 tzinfo-data 从 4 开始)希望这有帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM