首页 > 解决方案 > 我无法启动 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>'

标签: ruby-on-railsrubyrubygemsruby-on-rails-5

解决方案


我在运行时遇到了类似的错误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

推荐阅读