Rails服务器无法启动- 我该如何解决?

huangapple go评论57阅读模式
英文:

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 `&lt;main&gt;&#39;
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&#39;
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&#39;
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 `&lt;main&gt;&#39;
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&#39;
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&#39;
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;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
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&#39;
25: from config.ru:3:in `block in &lt;main&gt;&#39;
24: from config.ru:3:in `require_relative&#39;
23: from /Users/name/Development/Projects/movie_reviews/config/environment.rb:5:in `&lt;main&gt;&#39;
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!&#39;
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&#39;
20: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each&#39;
19: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each&#39;
18: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component&#39;
17: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `call&#39;
16: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:347:in `each&#39;
15: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component&#39;
14: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from&#39;
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&#39;
12: from /Users/name/.rbenv/versions/2.7.2/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each&#39;
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&#39;
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&#39;
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&#39;
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 &lt;module:Finisher&gt;&#39;
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&#39;
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&#39;
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&#39;
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!&#39;
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&#39;
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&#39;
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&#39;
/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&#39;: /Users/name/Development/Projects/movie_reviews/config/routes.rb:4: syntax error, unexpected end-of-input, expecting `end&#39; (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&#39; (SyntaxError)
You&#39;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>

huangapple
  • 本文由 发表于 2023年2月24日 12:01:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75552509.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定