gpt4 book ai didi

ruby-on-rails - 命令 'rails server' 不工作或 Rails 服务器命令不工作

转载 作者:行者123 更新时间:2023-12-04 19:27:23 26 4
gpt4 key购买 nike

当我运行“rails server”或“rails s”时出现错误。
您好,我正在学习 Rails,但出现错误
这是错误代码

Traceback (most recent call last):
52: from bin/rails:2:in `<main>'
51: from bin/rails:2:in `load'
50: from /home/wghu/Desktop/HelloRails/bin/spring:7:in `<top (required)>'
49: from /home/wghu/Desktop/HelloRails/bin/spring:7:in `tap'
48: from /home/wghu/Desktop/HelloRails/bin/spring:10:in `block in <top (required)>'
47: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
46: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
45: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
44: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/binstub.rb:11:in `load'
43: from /var/lib/gems/2.7.0/gems/spring-3.0.0/bin/spring:49:in `<top (required)>'
42: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/client.rb:30:in `run'
41: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/client/command.rb:7:in `call'
40: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/client/rails.rb:28:in `call'
39: from /var/lib/gems/2.7.0/gems/spring-3.0.0/lib/spring/client/rails.rb:28:in `load'
38: from /home/wghu/Desktop/HelloRails/bin/rails:4:in `<top (required)>'
37: from /home/wghu/Desktop/HelloRails/bin/rails:4:in `require_relative'
36: from /home/wghu/Desktop/HelloRails/config/boot.rb:4:in `<top (required)>'
35: from /home/wghu/Desktop/HelloRails/config/boot.rb:4:in `require'
34: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/setup.rb:4:in `<top (required)>'
33: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap.rb:112:in `default_setup'
32: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap.rb:70:in `setup'
31: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache.rb:20:in `setup'
30: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/yaml.rb:50:in `install!'
29: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/yaml.rb:55:in `init!'
28: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
27: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
26: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
25: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
24: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
23: from /usr/lib/ruby/2.7.0/yaml.rb:4:in `<main>'
22: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
21: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
20: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
19: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
18: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
17: from /usr/lib/ruby/2.7.0/psych.rb:15:in `<main>'
16: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
15: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
14: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
13: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
12: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
11: from /usr/lib/ruby/2.7.0/psych/nodes.rb:2:in `<main>'
10: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
9: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
8: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
7: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
6: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
5: from /usr/lib/ruby/2.7.0/psych/nodes/node.rb:2:in `<main>'
4: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
3: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
1: from /var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/lib/gems/2.7.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': superclass mismatch for class StringIO (TypeError)

我之前运行时的命令
rails g controller home index           
Ubuntu版本
21.10
我的 ruby 版本
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]

谢谢你帮助我

最佳答案

您的 Gemfile? 中指明了哪个 ruby​​ 版本
你安装了吗rbenvrvm ruby 版本管理器?
如果不是,我会建议您这样做,因为它会为每个项目(和全局)处理 Ruby 版本 很多更轻松。
你可以在 gorails 中查看这篇文章来安装 rbenv:Install Ruby On Rails onUbuntu#rbenv
小心 :如果选择安装rbenv请记住,拥有多个版本管理器是 想法,所以不要意外地继续安装 rvm .这些并不意味着在同一个系统中共存。只跟进这部分:rbenv install 3.0.2 (或任何你想要的版本——最好是你的 Gemfile 中的那个)rbenv global 3.0.2 (与您安装的版本相同)ruby -v在这些之后请重新运行bundle install在文件夹中并尝试运行 rails s再次。让我们知道这是怎么回事。

关于ruby-on-rails - 命令 'rails server' 不工作或 Rails 服务器命令不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69794498/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com