我似乎无法让Rails服务器运行

时间:2018-07-04 23:48:40

标签: mysql ruby-on-rails ruby server

我正在尝试制作我的第一个Rails应用程序,但是当我尝试运行rails server时,它却给了我很多文本。我正在arch Linux上运行此程序,并使用了AUR的ruby-rails捆绑软件。

这就是它尝试运行命令时给我的

[drew@rhino sophia]$ rails server
=> Booting Puma
=> Rails 5.2.0 application starting in development 
=> Run `rails server -h` for more startup options
Exiting
Traceback (most recent call last):
        70: from bin/rails:3:in `<main>'
        69: from bin/rails:3:in `load'
        68: from /home/drew/work/spproject/sophia/sophia/bin/spring:15:in `<top (required)>'
        67: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
        66: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
        65: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
        64: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
        63: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
        62: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
        61: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        60: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
        59: from /usr/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
        58: from /home/drew/work/spproject/sophia/sophia/bin/rails:9:in `<top (required)>'
        57: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
        56: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
        55: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
        54: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
        53: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
        52: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
        51: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
        50: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
        49: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
        48: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
        47: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
        46: from /usr/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        45: from /usr/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        44: from /usr/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        43: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
        42: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
        41: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:147:in `block in perform'
        40: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:51:in `start'
        39: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
        38: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/server.rb:354:in `wrapped_app'
        37: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:27:in `app'
        36: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/server.rb:219:in `app'
        35: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/server.rb:319:in `build_app_and_options_from_config'
        34: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/builder.rb:40:in `parse_file'
        33: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `new_from_string'
        32: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `eval'
        31: from config.ru:in `<main>'
        30: from config.ru:in `new'
        29: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
        28: from /usr/lib/ruby/gems/2.5.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
        27: from config.ru:3:in `block in <main>'
        26: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
        25: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
        24: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
        23: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
        22: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
        21: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
        20: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
        19: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
        18: from /usr/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
        17: from /home/drew/work/spproject/sophia/sophia/config/environment.rb:5:in `<main>'
        16: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
        15: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
        14: from /usr/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
        13: from /usr/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
        12: from /usr/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
        11: from /usr/lib/ruby/2.5.0/tsort.rb:347:in `call'
        10: from /usr/lib/ruby/2.5.0/tsort.rb:347:in `each'
         9: from /usr/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
         8: from /usr/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
         7: from /usr/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
         6: from /usr/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
         5: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
         4: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
         3: from /home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
         2: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/railtie.rb:42:in `block in <class:Railtie>'
         1: from /usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/core_ext/time/zones.rb:82:in `find_zone!'
/usr/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/core_ext/time/zones.rb:100:in `rescue in find_zone!': Invalid Timezone: UTC (ArgumentError)

编辑gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.7
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /home/drew/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/drew/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/2.5.0
     - /home/drew/.gem/ruby/2.5.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--user-install"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/local/sbin
     - /usr/lib/jvm/default/bin
     - /usr/bin/site_perl
     - /usr/bin/vendor_perl
     - /usr/bin/core_perl

粘贴$ PATH

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

粘贴application.rb

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Sophia
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.2

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
  end
end


Paster of rails migrate:db

rails aborted!
ArgumentError: Invalid Timezone: UTC
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
/home/drew/work/spproject/sophia/sophia/config/environment.rb:5:in `<main>'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:48:in `invoke'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
/home/drew/work/spproject/sophia/sophia/bin/rails:9:in `<top (required)>'
/home/drew/work/spproject/sophia/sophia/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

Caused by:
TZInfo::InvalidTimezoneIdentifier: Expected 44 bytes reading '/usr/share/zoneinfo/UTC', but got 0 bytes
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb:205:in `rescue in load_timezone_info'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb:202:in `load_timezone_info'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb:92:in `get'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
/home/drew/work/spproject/sophia/sophia/config/environment.rb:5:in `<main>'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:48:in `invoke'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
/home/drew/work/spproject/sophia/sophia/bin/rails:9:in `<top (required)>'
/home/drew/work/spproject/sophia/sophia/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

Caused by:
TZInfo::InvalidZoneinfoFile: Expected 44 bytes reading '/usr/share/zoneinfo/UTC', but got 0 bytes
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb:53:in `check_read'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb:169:in `parse'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb:28:in `block in initialize'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb:27:in `open'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_timezone_info.rb:27:in `initialize'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb:203:in `new'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/zoneinfo_data_source.rb:203:in `load_timezone_info'
/home/drew/.gem/ruby/2.5.0/gems/tzinfo-1.2.5/lib/tzinfo/timezone.rb:92:in `get'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `instance_exec'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:32:in `run'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:61:in `block in run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/initializable.rb:60:in `run_initializers'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:361:in `initialize!'
/home/drew/work/spproject/sophia/sophia/config/environment.rb:5:in `<main>'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:337:in `require_environment!'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:48:in `invoke'
/home/drew/.gem/ruby/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
/home/drew/work/spproject/sophia/sophia/bin/rails:9:in `<top (required)>'
/home/drew/work/spproject/sophia/sophia/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

4 个答案:

答案 0 :(得分:0)

请参见config/application.rb的{​​{1}}部分。

您可以运行config.time_zone以显示所有可用的时区。

答案 1 :(得分:0)

您可能正在等待迁移。尝试运行:

rails db:migrate

答案 2 :(得分:0)

time_zone添加到您的配置文件中,

config.time_zone = 'Australia/Melbourne'

您可以将其更改为应用程序所在的时区,也可以

config.time_zone = 'UTC'

答案 3 :(得分:0)

遇到相同的问题,表明我的队友已更改config / master.key代码。更新后,一切恢复正常。