Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method 'new' for Slack:Module #6

Open
mknarciso opened this issue Nov 15, 2018 · 7 comments
Open

Undefined method 'new' for Slack:Module #6

mknarciso opened this issue Nov 15, 2018 · 7 comments

Comments

@mknarciso
Copy link

Hi @ginjo !

Trying to change 'omniauth-slack' for 'ginjo-omniauth-slack' on the Gemfile gives me this error when I run the server:

/usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.2/lib/action_dispatch/middleware/stack.rb:35:in `build': undefined method `new' for Slack:Module (NoMethodError)
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.2/lib/action_dispatch/middleware/stack.rb:99:in `block in build'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.2/lib/action_dispatch/middleware/stack.rb:99:in `each'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.2/lib/action_dispatch/middleware/stack.rb:99:in `inject'
        from /usr/local/rvm/gems/ruby-2.3.4/gems/actionpack-5.1.2/lib/action_dispatch/middleware/stack.rb:99:in `build'
...

Using:

Rails 5.1.2
Puma 3.9.1
Ruby 2.3.4

Any advice on debbuging this?

@ginjo
Copy link
Owner

ginjo commented Nov 27, 2018

Hi @mknarciso , Just at a glance, it looks like .new is being called on OmniAuth::Slack, which is a module and doesn't have a .new method. If you could post some more info - stack trace, Gemfile, OmniAuth configuration block - I could get a better idea of what's going on. What version of ginjo-onmiauth-slack are you using?

@aguynamedben
Copy link

aguynamedben commented Dec 7, 2018

I'm also seeing this when trying to switch to this fork. It seems as if the config:

provider :slack, 'API_KEY', 'API_SECRET', scope: 'string-of-scopes'

is being called in my app, but the Slack module is not accessible by OmniAuth::Strategy:Slack. The Slack strategy isn't being added to OmniAuth.strategies when I inspect it in bundle exec rails c.

I have a bunch of OmniAuth strategies setup in my config/initializers/omniauth.rb, and I'm calling provider with:

    provider(provider_config[:omniauth_strategy_name], *provider_config[:omniauth_args])

For Slack, provider_config is

    {
      display_name: "Slack",
      omniauth_strategy_name: "slack", # I've tried a symbol here too
      omniauth_args: [
        ENV["SLACK_CLIENT_ID"], ENV["SLACK_CLIENT_SECRET"],
        scope: "files:read users:read users:read.email team:read identify"
      ],
    },

I've added puts around my initialization, and I'm positive provider is being called with :slack, but it's simply not added to OmniAuth.strategies for some reason.

omniauth 1.8.1
ginjo-omniauth-slack 2.4.1
omniauth-oauth 1.1.0
omniauth-oauth2 1.5.0
rails 5.1.6
ruby 2.3.3

I guess I will look at upgrading the omniauth version?

BTW, thank you for creating as fork of this library for the community to rally behind. It's a shame the other one was abandoned.

@ginjo
Copy link
Owner

ginjo commented Dec 10, 2018

Hi @aguynamedben , thanks for the info. Maybe it's a load-order issue somewhere in the library... I'll dig into the code and see what I can find.

@ginjo
Copy link
Owner

ginjo commented Dec 15, 2018

Hey folks, I had a look through the code, and I couldn't find any obvious point where this would happen. I wasn't able to reproduce it in my own examples, either. If this is an omniauth-slack bug, it's a tricky one.

I do have a couple of ideas on what might be happening, however.

1. It's possible that your middleware definition block has an error in the call to OmniAuth::Builder. I have done this plenty in my work with OmniAuth 😄.

If your code has use OmniAuth::Slack, it will raise the exact exception you posted above. It should look like this, instead:

use OmniAuth::Builder do |env|
  provider :slack,
    SLACK_OAUTH_KEY,
    SLACK_OAUTH_SECRET,
    scope: 'string-of-space-delimited-scopes'
end

2. I have an as-yet-unreleased version that did have a bug confusing the OmniAuth::Slack module with the OmniAuth::Strategies::Slack class. The bug has been fixed in Master, but it still exists in some of the interim commits. If you happen to be running this gem directly from github, on a version somewhere between v2.4.1 and 12ab2d0, you could see an error similar to the one posted above.

If neither of these fits your situation, please post the full stack trace from the error, if possible, and I'll look deeper into it.

@aguynamedben
Copy link

aguynamedben commented Jan 3, 2019

Thanks for looking into this. I'm pretty sure our provider call is correct.

Candidly I don't have time to dig into this right now. We pinned the repo to:

# https://github.com/kmrshntr/omniauth-slack/issues/63
# For now, use master as of 2018-12-07, for omniauth-oauth2 version
gem "omniauth-slack", github: "kmrshntr/omniauth-slack", ref: "afd9f5c"

In the future I will try switching to your fork and let you know if this pops up again.

@talecK
Copy link

talecK commented May 18, 2019

hey @aguynamedben - just a quick sanity check, are you including the gem as follows in your gemfile?
gem 'ginjo-omniauth-slack', require: 'omniauth-slack'

I was banging my head against the exact same error until I realized I forgot the 'require' :(

@aguynamedben
Copy link

@talecK I have not tried that, but will at some point soon... thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants