[英]Command 'rails server' not working or Rails server command not working
您好,我正在學習 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]
您的 ruby 版本2.7.4
和文件夾 rails s 用於 gems /var/lib/gems/2.7.0/
會向我表明某種版本不匹配。
您的Gemfile?
指明了哪個 ruby 版本Gemfile?
您是否安裝了rbenv
或rvm
ruby 版本管理器?
如果不是,我建議您這樣做,因為它使每個項目(和全局)的 Ruby 版本處理更加容易。
你可以在 gorails 中查看這篇文章來安裝 rbenv:在 Ubuntu#rbenv 上安裝 Ruby On Rails
小心:如果您選擇安裝rbenv
請記住有多個版本管理器是一個壞主意,所以不要意外地繼續安裝rvm
。 這些並不意味着共存於同一個系統中。 只跟進這部分:
rbenv install 3.0.2
(或者你想要的任何版本——最好是你 Gemfile 中的那個)
rbenv global 3.0.2
(與您安裝的版本相同)
ruby -v
在這些之后,請重新運行文件夾中的bundle install
並嘗試再次運行rails s
。 讓我們知道這是怎么回事。
更新我的寶石后,我開始收到此錯誤。 我嘗試卸載 ruby 和我所有的 gems,更新 rvm,但對我來說,解決方案似乎是更新 rubygems。
gem update --system
使用以下命令從您的 gem 列表中刪除 StringIO。 它對我有用,我希望它也能解決你的問題。
gem uninstall stringio
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.