无法启动rails服务器(错误的URI(不是URI?):tcp:// localhost:5000:3000)

问题描述 投票:1回答:1

在创建新的rails项目并通过键入rails s启动服务器时,它每次都会崩溃。我创建新项目并尝试运行rails s如下:

rails s 
=> Booting Puma
=> Rails 5.2.1 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
Exiting
Traceback (most recent call last):
40: from bin/rails:3:in `<main>'
39: from bin/rails:3:in `load'
38: from /media/se7a/1C40A4ED40A4CEB8/temp_rails_projec/bin/spring:15:in `<top (required)>'
37: from /media/se7a/1C40A4ED40A4CEB8/temp_rails_projec/bin/spring:15:in `require'
36: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
35: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
34: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
33: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
32: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
31: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
30: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
29: from /media/se7a/1C40A4ED40A4CEB8/temp_rails_projec/bin/rails:9:in `<top (required)>'
28: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
27: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
26: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
25: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
24: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
23: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
22: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
21: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
20: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<main>'
19: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
18: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
17: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
16: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
15: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
14: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
13: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
12: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
11: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:53:in `start'
10: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/rack-2.0.5/lib/rack/server.rb:297:in `start'
 9: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/rack/handler/puma.rb:70:in `run'
 8: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/launcher.rb:184:in `run'
 7: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/single.rb:96:in `run'
 6: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/runner.rb:151:in `load_and_bind'
 5: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/binder.rb:88:in `parse'
 4: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/binder.rb:88:in `each'
 3: from /home/se7a/.rvm/gems/ruby-2.5.1/gems/puma-3.12.0/lib/puma/binder.rb:89:in `block in parse'
 2: from /home/se7a/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/uri/common.rb:237:in `parse'
 1: from /home/se7a/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/uri/rfc3986_parser.rb:73:in `parse'
/home/se7a/.rvm/rubies/ruby- 
 2.5.1/lib/ruby/2.5.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): tcp://localhost:5000:3000 (URI::InvalidURIError)
ruby-on-rails ruby-on-rails-5 puma
1个回答
0
投票

- 检查你的网址是不是零,这是一个有效的网址。 -do URI.encode(url)在URI.parse之前(以避免特殊字符)-Do strip到你传递给URI.parse的字符串(以避免前导和尾随空格)。一体:

uri = URI.parse(URI.encode(url.strip))
© www.soinside.com 2019 - 2024. All rights reserved.