[英]Command 'rails server' not working or Rails server command not working
Hello I am learning Rails And I got error您好,我正在学习 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
21.10
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]
Your ruby version 2.7.4
and the folder rails s is using for the gems /var/lib/gems/2.7.0/
would indicate some kind of version mismatch to me.您的 ruby 版本
2.7.4
和文件夹 rails s 用于 gems /var/lib/gems/2.7.0/
会向我表明某种版本不匹配。
Which ruby version is indicated in your Gemfile?
您的
Gemfile?
指明了哪个 ruby 版本Gemfile?
Have you installed rbenv
or rvm
ruby version managers?您是否安装了
rbenv
或rvm
ruby 版本管理器?
If not i would advise you to do so as it makes Ruby version handling for each project (and globally) much easier.如果不是,我建议您这样做,因为它使每个项目(和全局)的 Ruby 版本处理更加容易。
You can check this article in gorails to install rbenv: Install Ruby On Rails on Ubuntu#rbenv你可以在 gorails 中查看这篇文章来安装 rbenv:在 Ubuntu#rbenv 上安装 Ruby On Rails
CAREFUL : If you choose to install rbenv
keep in mind having multiple version managers is a BAD idea, so do not accidentally proceed with installing rvm
.小心:如果您选择安装
rbenv
请记住有多个版本管理器是一个坏主意,所以不要意外地继续安装rvm
。 Those are not meant to coexist in the same system.这些并不意味着共存于同一个系统中。 Only follow up to this part:
只跟进这部分:
rbenv install 3.0.2
(or whatever version you wish - preferably the one in your Gemfile) rbenv install 3.0.2
(或者你想要的任何版本——最好是你 Gemfile 中的那个)
rbenv global 3.0.2
(the same version you installed) rbenv global 3.0.2
(与您安装的版本相同)
ruby -v
After these please rerun bundle install
in the folder and try to run rails s
again.在这些之后,请重新运行文件夹中的
bundle install
并尝试再次运行rails s
。 Let us know how that went.让我们知道这是怎么回事。
I started getting this error after updating my gems.更新我的宝石后,我开始收到此错误。 I tried uninstalling ruby and all my gems, updating rvm, but for me the solution appeared to be updating rubygems.
我尝试卸载 ruby 和我所有的 gems,更新 rvm,但对我来说,解决方案似乎是更新 rubygems。
gem update --system
Remove StringIO from your gem list by using below command.使用以下命令从您的 gem 列表中删除 StringIO。 It works for me and I hope it will fix your issue as well.
它对我有用,我希望它也能解决你的问题。
gem uninstall stringio
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.