slack-ruby / slack-ruby-bot-server

A library that enables you to write a complete Slack bot service with Slack button integration, in Ruby.
MIT License
268 stars 74 forks source link

NameError: uninitialized constant SlackRubyBotServer::Api::Presenters::TeamPresenter::Boolean w/mongoid 7.3.x #138

Closed dwyn closed 3 years ago

dwyn commented 3 years ago

Hiya!

I am actually using slack-ruby-bot-server in another slack-bot rails app. This is the repo. When running rails s, I receive the following error:

/Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:13:in `<module:TeamPresenter>': uninitialized constant SlackRubyBotServer::Api::Presenters::TeamPresenter::Boolean (NameError)

This is the entire stack trace.

➜ rails s
/Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:13:in `<module:TeamPresenter>': uninitialized constant SlackRubyBotServer::Api::Presenters::TeamPresenter::Boolean (NameError)
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:4:in `<module:Presenters>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:3:in `<module:Api>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:2:in `<module:SlackRubyBotServer>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters/team_presenter.rb:1:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api/presenters.rb:7:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server/api.rb:7:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/slack-ruby-bot-server-1.2.0/lib/slack-ruby-bot-server.rb:13:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler/runtime.rb:61:in `each'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler/runtime.rb:61:in `block in require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler/runtime.rb:50:in `each'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler/runtime.rb:50:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bundler-2.2.18/lib/bundler.rb:174:in `require'
        from /Users/dharmon/Development/CMM/cipherbot/config/application.rb:20:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/railties-6.1.3.2/lib/rails/commands/server/server_command.rb:138:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/railties-6.1.3.2/lib/rails/commands/server/server_command.rb:135:in `perform'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/railties-6.1.3.2/lib/rails/command/base.rb:69:in `perform'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/railties-6.1.3.2/lib/rails/command.rb:50:in `invoke'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in `<main>'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/dharmon/.rvm/gems/ruby-3.0.1/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from bin/rails:4:in `<main>'

This is my Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.1'
# ruby '2.7.2'

# Load env variables
gem 'dotenv-rails', '~> 2.7', require: 'dotenv/rails-now' 
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
# gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
gem 'rails', '~> 6.1.0'#, '>= 6.0.3.3'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'

# ODM for mongodb
gem 'mongoid'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Slack Ruby Bot Server
gem 'slack-ruby-bot-server', '~> 1.2.0 '
gem 'kaminari-mongoid'
gem 'mongoid-scroll'
gem 'slack-ruby-bot-server-events', github: 'slack-ruby/slack-ruby-bot-server-events', branch: 'master'

Any suggestions on debugging this error? Thanks in advance!

dblock commented 3 years ago

This comes from Grape, https://github.com/ruby-grape/grape/blob/master/lib/grape/validations/validators/coerce.rb#L5, so it' probably something about order of includes. I can take a look if you haven't found a solution yet?

dwyn commented 3 years ago

I haven't found a solution yet. I can try tracking down which includes may be out of order. I'm open to any other suggestions you have. Thanks in advance!

dblock commented 3 years ago

Broke because https://jira.mongodb.org/browse/MONGOID-4753 was implemented.

dblock commented 3 years ago

Someone has already tried to fix this in https://github.com/slack-ruby/slack-ruby-bot-server/pull/137, linking here.

dblock commented 3 years ago

Fixed in #140.