gpt4 book ai didi

ruby-on-rails - Spring和中间件冲突?

转载 作者:行者123 更新时间:2023-12-03 16:26:48 25 4
gpt4 key购买 nike

我正在尝试使用 Google 添加 oauth2,关注 these instructions .

我在启动服务器时收到以下错误消息:

Exiting
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).

This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.

Here's the backtrace:

/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `load'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `block in load'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:287:in `load'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
/Users/omonia/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
/Users/omonia/Dropbox/MyApp/bin/spring:13:in `<top (required)>'

安装的相关 gem :
gem 'google-api-client', '0.9'
gem 'omniauth'
gem 'omniauth-google_oauth2'

以下代码添加到 config/initializers/omniauth.rb:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, 'my Google client id', 'my Google client secret', {client_options: {ssl: {ca_file: Rails.root.join("cacert.pem").to_s}}}
end

这里发生了什么?遵循错误说明不会改变任何内容(Spring 是最新版本 1.7.2 并且运行 bundle exec spring binstub --all 仅返回“spring 已经存在”)。

最佳答案

把我的 comment作为答案,因为 OP 确认它确实帮助了他。请按照以下步骤安装新 Spring 并解决问题:

  • 运行此 bin/spring binstub --remove --all
  • 从 Gemfile 中删除 gem 并运行 bundle install .
  • 现在添加 gem "spring", group: :development在 Gemfile 中,运行 bundle installbundle exec spring binstub --all关注 doc .现在一切都应该好了。
  • 关于ruby-on-rails - Spring和中间件冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38664754/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com