首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >命令“Rails服务器”不能工作,或者Rails服务器命令不能工作

命令“Rails服务器”不能工作,或者Rails服务器命令不能工作
EN

Stack Overflow用户
提问于 2021-11-01 08:43:50
回答 3查看 674关注 0票数 0

当我运行"rails服务器“或"rails s”时,我得到了一个错误。

你好,我正在学习Rails,我得到了错误

这是错误代码

代码语言:javascript
复制
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)

之前运行时的命令

代码语言:javascript
复制
rails g controller home index           

ubuntu版本

代码语言:javascript
复制
21.10

我的红宝石版本

代码语言:javascript
复制
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]

谢谢你帮我

EN

回答 3

Stack Overflow用户

发布于 2021-11-01 11:55:24

在您的Gemfile?中指明了哪个红宝石版本

您是否安装了rbenvrvm ruby版本管理器?

如果不是,我建议您这样做,因为它使每个项目(以及全球范围内)的Ruby处理更加容易,也更容易。

您可以在gorails中查看本文以安装rbenv:Install Ruby On Rails on Ubuntu#rbenv

小心:如果您选择安装rbenv,请记住多个版本管理器是不好的想法,所以不要意外地继续安装rvm。这并不意味着要在同一个系统中共存。只对这一部分采取后续行动:

rbenv install 3.0.2 (或者你想要的任何版本-最好是你的Gemfile中的那个)

rbenv global 3.0.2 (与您安装的版本相同)

ruby -v

之后,请在文件夹中重新运行bundle install,然后再次运行rails s。让我们知道进展如何。

票数 0
EN

Stack Overflow用户

发布于 2021-11-19 19:22:08

在更新了我的宝石之后,我开始得到这个错误。我试着卸载ruby和我所有的gems,更新rvm,但对我来说,解决方案似乎是更新rubygems。

代码语言:javascript
复制
gem update --system
票数 0
EN

Stack Overflow用户

发布于 2022-09-25 09:06:27

使用下面的命令从gem列表中删除StringIO。它对我有效,我希望它也能解决你的问题。

代码语言:javascript
复制
gem uninstall stringio
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69794498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档