Rails 生成设计安装问题(LoadError 文件)

Rails generate devise install problem (LoadError files)

当我在cmd中运行这个命令时-rails生成devise:install

我遇到了这个问题

C:\Users\Andrew\instagram-clone>rails generate devise:install
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- 3.0/pg_ext (LoadError)
Did you mean?  3.0.0/devkit
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `block in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:299:in `load_dependency'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:14:in `rescue in <main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:3:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:61:in `block in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:50:in `each'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:50:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler.rb:173:in `require'
    from C:/Users/Andrew/instagram-clone/config/application.rb:7:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/actions.rb:22:in `require_application!'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/actions.rb:14:in `require_application_and_environment!'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands/generate/generate_command.rb:21:in `perform'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/base.rb:69:in `perform'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command.rb:50:in `invoke'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from bin/rails:4:in `<main>'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- pg_ext (LoadError)
C:\Users\Andrew\instagram-clone>rails generate devise:install
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- 3.0/pg_ext (LoadError)
Did you mean?  3.0.0/devkit
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `block in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:299:in `load_dependency'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:14:in `rescue in <main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-0.18.4-x64-mingw32/lib/pg.rb:3:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:61:in `each'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:61:in `block in require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:50:in `each'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/runtime.rb:50:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler.rb:173:in `require'
    from C:/Users/Andrew/instagram-clone/config/application.rb:7:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/actions.rb:22:in `require_application!'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/actions.rb:14:in `require_application_and_environment!'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands/generate/generate_command.rb:21:in `perform'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/base.rb:69:in `perform'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command.rb:50:in `invoke'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in `<main>'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    from bin/rails:4:in `<main>'
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- pg_ext (LoadError)

也许smb有同样的错误? 非常感谢您的回答 Thx

堆栈跟踪似乎表明您没有在目标机器上安装 PostgreSQL 库。因此,要解决该问题,您可以下载软件的稳定版本 here 并确保在安装过程中检查了开发库。这将要求您在安装后关闭并重新打开所有活动的 cmd 会话。

之后,重新运行 bundle install --force(如果您使用的是早于 2.1 的捆绑器)或 bundle install --redownload(如果您使用的是 Bundler 2.1 或更高版本)Rails 项目,应该能够正确编译和运行。

如果它已安装但无法使用上述选项,请通过执行 gem install pg -f 重新安装 gem 或通过 gem install pg --pre 看看他们能否解决您的问题。