英文:
Rails server not starting- how do I resolve?
问题
我正在使用rails server命令,但出现了多个错误消息。 请建议如何进行故障排除和解决? 谢谢
Traceback (most recent call last):
46: from bin/rails:4:in `<main>'
45: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
44: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'require'
43: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands.rb:18:in '<main>'
42: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/command.rb:48:in 'invoke'
41: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/command/base.rb:87:in 'perform'
40: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in 'dispatch'
39: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in 'invoke_command'
38: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in 'run'
37: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:134:in 'perform'
36: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:134:in 'tap'
35: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:143:in 'block in perform'
34: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:36:in 'start'
33: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:76:in 'log_to_stdout'
32: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:422:in 'wrapped_app'
31: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:249:in 'app'
30: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:349:in 'build_app_and_options_from_config'
29: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:66:in 'parse_file'
28: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:105:in 'load_file'
27: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in 'new_from_string'
26: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in 'eval'
25: from config.ru:3:in 'block in <main>'
24: from config.ru:3:in 'require_relative'
23: from /Users/name/Development/Projects/movie_reviews/config/environment.rb:5:in '<main>'
22: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application.rb:372:in 'initialize!'
21: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/initializable.rb:60:in 'run_initializers'
20: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:205:in 'tsort_each'
19: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:226:in 'tsort_each'
18: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in 'each_strongly_connected_component'
17: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in '
<details>
<summary>英文:</summary>
I am using rails server command, but getting multiple error messages. Please advise- how do I trouble shoot and resolve? tks
Traceback (most recent call last):
46: from bin/rails:4:in `<main>'
45: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
44: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
43: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands.rb:18:in `<main>'
42: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/command.rb:48:in `invoke'
41: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/command/base.rb:87:in `perform'
40: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
39: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
38: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
37: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:134:in `perform'
36: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:134:in `tap'
35: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:143:in `block in perform'
34: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:36:in `start'
33: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
32: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:422:in `wrapped_app'
31: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:249:in `app'
30: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/server.rb:349:in `build_app_and_options_from_config'
29: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:66:in `parse_file'
28: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:105:in `load_file'
27: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in `new_from_string'
26: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.6.2/lib/rack/builder.rb:116:in `eval'
25: from config.ru:3:in `block in <main>'
24: from config.ru:3:in `require_relative'
23: from /Users/name/Development/Projects/movie_reviews/config/environment.rb:5:in `<main>'
22: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application.rb:372:in `initialize!'
21: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/initializable.rb:60:in `run_initializers'
20: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
19: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
18: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
17: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `call'
16: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each'
15: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
14: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
13: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
12: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
11: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/initializable.rb:61:in `block in run_initializers'
10: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/initializable.rb:32:in `run'
9: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/initializable.rb:32:in `instance_exec'
8: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/finisher.rb:158:in `block in <module:Finisher>'
7: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:13:in `execute'
6: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activesupport-7.0.4.2/lib/active_support/file_update_checker.rb:83:in `execute'
5: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:38:in `block in updater'
4: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:24:in `reload!'
3: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:50:in `load_paths'
2: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:50:in `each'
1: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:50:in `block in load_paths'
/Users/name/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/railties-7.0.4.2/lib/rails/application/routes_reloader.rb:50:in `load': /Users/name/Development/Projects/movie_reviews/config/routes.rb:4: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
</details>
# 答案1
**得分**: 2
检查你的错误日志中的最后一行:
`/Users/name/Development/Projects/movie_reviews/config/routes.rb:4: 语法错误,意外的输入结束,期望 'end' (SyntaxError)`
在你的 `routes.rb` 文件中某处缺少了一个 `end`(可能在第4行左右)。
你可以使用以下命令检查文件中是否存在语法错误:
`ruby -cw config/routes.rb`
<details>
<summary>英文:</summary>
Check the last line from your error log
/Users/name/Development/Projects/movie_reviews/config/routes.rb:4: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
You're missing an end somewhere in your `routes.rb` (possibly around line 4)
You can check if there is any syntax error on the file using
ruby -cw config/routes.rb
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论