2

私はthese instructionsに続いて、Googleにoauth2を追加しようとしています。春とミドルウェアの競合?

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 '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 already present」のみを返します)。

+0

'Spring'をアップグレードしましたか? –

+0

最初に 'bin/spring binstub --remove --all'を実行してから' bundle exec spring binstub --all'を実行できますか?これらのすべてのコマンドを –

+0

私は今あなたの手順に従っているが、まだ同じエラーメッセージをアップグレードすることを確認してください。私はこれが新しいアプリであることを付け加えるべきで、まったく混乱しないコードはほとんどありません。追加する2つ目のこと:omniauth-initializerでコードを削除すると、もうエラーは発生しません。 –

答えて

0

私はcommentを答えとしてOPが彼を助けてくれたと確信しています。

  • 実行このbin/spring binstub --remove --all
  • はGemfileから宝石を削除し、bundle installを実行します。新しい春をインストールして問題を解決するには、以下の手順に従ってください。
  • Gemfileにgem "spring", group: :developmentを追加し、bundle installbundle exec spring binstub --alldocと実行してください。今はすべてうまくいくはずです。
0

チェック設定/初期化子/ omniauth.rbファイルとあなたがコンテンツを、次のしていることを確認してください。

Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :google, 'Client_Id', 'Client_Secret' 
end 

をあなたが正確にGoogleのプロバイダを持っていることを確認してください(GitHubのか、Facebookのではない)

0

これは私のために働いたものです -

コンソールでこれを実行しました - rake rails:update:bin

次に実行しましたbundle exec spring binstub --all

これがすべてで機能するとは限りません。

ありがとう:)

関連する問題