ruby-on-rails - 我无法启动 Rails 服务器
问题描述
我认为这一定是与路径有关的问题。我一步一步地制作了这个页面https://meekgonkey.blogspot.com/2014/02/installing-ruby-rails-on-manjaro-linux.html
/usr/lib/ruby/3.0.0/pathname.rb:20: warning: already initialized constant Pathname::TO_PATH
/home/vitaopb/.local/share/gem/ruby/3.0.0/gems/pathname-0.2.0/lib/pathname.rb:20: warning: previous definition of TO_PATH was here
/usr/lib/ruby/3.0.0/pathname.rb:22: warning: already initialized constant Pathname::SAME_PATHS
/home/vitaopb/.local/share/gem/ruby/3.0.0/gems/pathname-0.2.0/lib/pathname.rb:22: warning: previous definition of SAME_PATHS was here
/usr/lib/ruby/3.0.0/pathname.rb:34: warning: already initialized constant Pathname::SEPARATOR_LIST
/home/vitaopb/.local/share/gem/ruby/3.0.0/gems/pathname-0.2.0/lib/pathname.rb:34: warning: previous definition of SEPARATOR_LIST was here
/usr/lib/ruby/3.0.0/pathname.rb:35: warning: already initialized constant Pathname::SEPARATOR_PAT
/home/vitaopb/.local/share/gem/ruby/3.0.0/gems/pathname-0.2.0/lib/pathname.rb:35: warning: previous definition of SEPARATOR_PAT was here
/usr/lib/ruby/3.0.0/pathname.rb:41: warning: already initialized constant Pathname::ABSOLUTE_PATH
/home/vitaopb/.local/share/gem/ruby/3.0.0/gems/pathname-0.2.0/lib/pathname.rb:41: warning: previous definition of ABSOLUTE_PATH was here
/usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/path.rb:103:in `to_s': unexpected @path (TypeError)
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/path.rb:103:in `stability'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/path.rb:11:in `stable?'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/path.rb:41:in `entries_and_dirs'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:159:in `block (2 levels) in unshift_paths_locked'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:155:in `reverse_each'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:155:in `block in unshift_paths_locked'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/store.rb:47:in `block in transaction'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/store.rb:45:in `synchronize'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/store.rb:45:in `transaction'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:154:in `unshift_paths_locked'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:107:in `block in unshift_paths'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:107:in `synchronize'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/cache.rb:107:in `unshift_paths'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/change_observer.rb:21:in `unshift'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/application.rb:361:in `add_lib_to_load_path!'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/application.rb:95:in `inherited'
from /home/vitaopb/Documentos/rails/app-Tes/config/application.rb:11:in `<module:AppTes>'
from /home/vitaopb/Documentos/rails/app-Tes/config/application.rb:9:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:138:in `block in perform'
from <internal:kernel>:90:in `tap'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/commands/server/server_command.rb:135:in `perform'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/command/base.rb:69:in `perform'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/command.rb:48:in `invoke'
from /home/vitaopb/.local/share/gem/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/commands.rb:18:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /home/vitaopb/Documentos/rails/app-Tes/bin/rails:5:in `<top (required)>'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/client/rails.rb:28:in `load'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/client/rails.rb:28:in `call'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/client/command.rb:7:in `call'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/client.rb:30:in `run'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/bin/spring:49:in `<top (required)>'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/binstub.rb:11:in `load'
from /usr/lib/ruby/gems/3.0.0/gems/spring-3.0.0/lib/spring/binstub.rb:11:in `<top (required)>'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from /home/vitaopb/Documentos/rails/app-Tes/bin/spring:10:in `block in <top (required)>'
from <internal:kernel>:90:in `tap'
from /home/vitaopb/Documentos/rails/app-Tes/bin/spring:7:in `<top (required)>'
from bin/rails:2:in `load'
from bin/rails:2:in `<main>'
解决方案
我在运行时遇到了类似的错误rails new <ProjectName>
。设法使用解决方法创建项目,但后来在尝试rails s
.
由于某种原因bundle exec rails s
会引发一个冗长的神秘错误,并以中止和核心转储结束。
卸载所有 gem 并为我的 rbenv 版本重新安装它们为我修复了它。
$ gem uninstall -aIx
$ gem install rails -v 6.1.4.1
$ rbenv rehash
(此时 rbenv 抛出另一个错误,说 /home/.../.rbenv-shim 存在,然后我跑了..)
$ rm /home/username/.rbenv/shims/.rbenv-shim
$ rbenv rehash
推荐阅读
- php - 如果同时插入两条记录,如何获取最后一个ID
- awk - 合并两个文件并将行转置为列
- python - 在道路网络坐标列表中查找到给定点的最近点
- python - 麻烦'Pip'下载特定的Python模块
- c# - 如何验证 api 参数
- gmail-api - Gmail API 中缺少的功能
- java - 使用匿名比较器的 ArraySort 会出错
- reactjs - 反应原生视图不更新
- ffmpeg - ffmpeg 无法将 mp4 转换为 mp3 输出文件 #0 不包含任何流
- postgresql - “org.hibernate.PersistentObjectException:分离的实体传递给持久化”错误经过大量研发后没有得到解决