为什么 Rails 控制台命令不起作用?
Why is Rails Console command not working?
感谢您花时间阅读本文。我对此 非常 陌生,目前正在按照教科书进行学习 Rails,如果我学得慢,请见谅。我遇到的大多数障碍我都可以 google 然后点击,但恐怕我在这个问题上处于停滞状态。是的,我确实在这里寻找类似的东西 questions/answers,那些也没有帮助。
命令 $ Rails 控制台 不起作用。现在,在输入这个命令之前,我确实尝试输入了 $ nano ~/.irbrc ,我不知道我是否正确地做了那一步,我不知道是否影响 $ Rails 控制台命令。在此之前,我还输入了 $ Spring Stop — 甚至在此之前,我仍然收到同样的错误,但我离题了。
这是我输入控制台命令时发生的情况:
ubuntu:~/environment $ cd sample_app
ubuntu:~/environment/sample_app (master) $ rails console
Running via Spring preloader in process 2921
Loading development environment (Rails 6.0.3.1)
Traceback (most recent call last):
44: from -e:1:in `<main>'
43: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
42: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
41: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
40: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
39: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
38: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
37: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `serve'
36: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `fork'
35: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:215:in `block in serve'
34: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/command_wrapper.rb:38:in `call'
33: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/commands/rails.rb:6:in `call'
32: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
31: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
30: from /home/ubuntu/environment/sample_app/bin/rails:9:in `<main>'
29: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
28: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
27: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
26: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
25: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
24: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
23: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<main>'
22: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command.rb:46:in `invoke'
21: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command/base.rb:69:in `perform'
20: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
19: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
18: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
17: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:102:in `perform'
16: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:19:in `start'
15: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:70:in `start'
14: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb.rb:376:in `start'
13: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb/init.rb:20:in `setup'
12: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb/init.rb:228:in `run_config'
11: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
10: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
9: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/.irbrc:11:in `<main>'
8: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
7: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
6: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
5: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
4: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
3: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2: from /home/ubuntu/.rvm/scripts/irbrc.rb:40:in `<main>'
1: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load': /home/ubuntu/.irbrc:4: unterminated regexp meets end of file (SyntaxError)
...conf[:AUTO_INDENT_MODE] = false
...
这个时候,我是不是应该从头再来?有没有办法解决这个问题?非常感谢你们!
您的 /home/ubuntu/.irbrc
文件中存在语法错误。这意味着有代码格式不正确,无法被Ruby解析。使用您的文件时,Ruby 认为有一个未完成的正则表达式,但它可能只是一个无效的 character/formatting,看起来像一个未完成的 rexex。无论如何,您需要检查该文件的内容,以确定其中包含的逻辑是否符合您的预期。
感谢您花时间阅读本文。我对此 非常 陌生,目前正在按照教科书进行学习 Rails,如果我学得慢,请见谅。我遇到的大多数障碍我都可以 google 然后点击,但恐怕我在这个问题上处于停滞状态。是的,我确实在这里寻找类似的东西 questions/answers,那些也没有帮助。
命令 $ Rails 控制台 不起作用。现在,在输入这个命令之前,我确实尝试输入了 $ nano ~/.irbrc ,我不知道我是否正确地做了那一步,我不知道是否影响 $ Rails 控制台命令。在此之前,我还输入了 $ Spring Stop — 甚至在此之前,我仍然收到同样的错误,但我离题了。
这是我输入控制台命令时发生的情况:
ubuntu:~/environment $ cd sample_app
ubuntu:~/environment/sample_app (master) $ rails console
Running via Spring preloader in process 2921
Loading development environment (Rails 6.0.3.1)
Traceback (most recent call last):
44: from -e:1:in `<main>'
43: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
42: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
41: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
40: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `run'
39: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:139:in `loop'
38: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:145:in `block in run'
37: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `serve'
36: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:175:in `fork'
35: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/application.rb:215:in `block in serve'
34: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/command_wrapper.rb:38:in `call'
33: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/spring-2.1.0/lib/spring/commands/rails.rb:6:in `call'
32: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
31: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
30: from /home/ubuntu/environment/sample_app/bin/rails:9:in `<main>'
29: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
28: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
27: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
26: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
25: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
24: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
23: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<main>'
22: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command.rb:46:in `invoke'
21: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/command/base.rb:69:in `perform'
20: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
19: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
18: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
17: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:102:in `perform'
16: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:19:in `start'
15: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/railties-6.0.3.1/lib/rails/commands/console/console_command.rb:70:in `start'
14: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb.rb:376:in `start'
13: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb/init.rb:20:in `setup'
12: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/irb/init.rb:228:in `run_config'
11: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
10: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
9: from /home/ubuntu/.rvm/rubies/ruby-2.6.3/.irbrc:11:in `<main>'
8: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
7: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
6: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
5: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
4: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
3: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2: from /home/ubuntu/.rvm/scripts/irbrc.rb:40:in `<main>'
1: from /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load': /home/ubuntu/.irbrc:4: unterminated regexp meets end of file (SyntaxError)
...conf[:AUTO_INDENT_MODE] = false
...
这个时候,我是不是应该从头再来?有没有办法解决这个问题?非常感谢你们!
您的 /home/ubuntu/.irbrc
文件中存在语法错误。这意味着有代码格式不正确,无法被Ruby解析。使用您的文件时,Ruby 认为有一个未完成的正则表达式,但它可能只是一个无效的 character/formatting,看起来像一个未完成的 rexex。无论如何,您需要检查该文件的内容,以确定其中包含的逻辑是否符合您的预期。