While trying to install doorkeeper 4.2.6 into an existing Rails 5.0.1 application, I ran into the following problem:
$ rails generate doorkeeper:install
~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/doorkeeper-4.2.6/lib/doorkeeper/config.rb:18:in `configuration': Configuration for doorkeeper missing. Do you have doorkeeper initializer? (Doorkeeper::MissingConfiguration)
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/doorkeeper-4.2.6/app/controllers/doorkeeper/application_controller.rb:3:in `<module:Doorkeeper>'
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/doorkeeper-4.2.6/app/controllers/doorkeeper/application_controller.rb:1:in `<top (required)>'
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:477:in `load'
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:477:in `block in load_file'
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:662:in `new_constants_in'
from ~/.rvm/gems/ruby-2.3.3@clear_value_plus/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:476:in `load_file'
same here
$ rails --version
Rails 5.1.1
$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
$ bundle install
...
$ rails generate doorkeeper:install
/usr/local/bundle/gems/doorkeeper-4.2.6/lib/doorkeeper/config.rb:18:in `configuration': Configuration for doorkeeper missing. Do you have doorkeeper initializer? (Doorkeeper::MissingConfiguration)
from /usr/local/bundle/gems/doorkeeper-4.2.6/app/controllers/doorkeeper/application_controller.rb:3:in `<module:Doorkeeper>'
from /usr/local/bundle/gems/doorkeeper-4.2.6/app/controllers/doorkeeper/application_controller.rb:1:in `<top (required)>'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `block in require'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:258:in `load_dependency'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:379:in `block in require_or_load'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:36:in `block in load_interlock'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:36:in `load_interlock'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:357:in `require_or_load'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:335:in `depend_on'
from /usr/local/bundle/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:251:in `require_dependency'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:475:in `each'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:475:in `block in eager_load!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:473:in `each'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:473:in `eager_load!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/engine.rb:354:in `eager_load!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/application/finisher.rb:67:in `each'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/initializable.rb:30:in `run'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/initializable.rb:59:in `block in run_initializers'
from /usr/local/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
from /usr/local/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/local/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each'
from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `call'
from /usr/local/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/local/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
from /usr/local/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/initializable.rb:58:in `run_initializers'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/application.rb:353:in `initialize!'
from /app/config/environment.rb:5:in `<top (required)>'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/application.rb:329:in `require'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/application.rb:329:in `require_environment!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/command/actions.rb:16:in `require_application_and_environment!'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/commands/generate/generate_command.rb:19:in `perform'
from /usr/local/bundle/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/bundle/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/command/base.rb:63:in `perform'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/command.rb:44:in `invoke'
from /usr/local/bundle/gems/railties-5.1.1/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
On a complete fresh rails 5.1.1 ruby 2.4.1 app it works. Looks like the installation of doorkeeper fails for some reason on existing rails projects, maybe if some initializers, helpers, config from other gems exists already!?
@agrohmann I have a Rails 5.1.1 application on Ruby 2.3 and there are no problems with Doorkeeper gem when trying to install it.
$ rails --version
Rails 5.1.1
$ ruby --version
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Installation:
$ rails generate doorkeeper:install
create config/initializers/doorkeeper.rb
create config/locales/doorkeeper.en.yml
route use_doorkeeper
===============================================================================
Can't reproduce it.
Had the same problem, looks like rails loads up Doorkeeper::ApplicationController which calls Doorkeeper.configuration which in turn will fail with Doorkeeper::MissingConfiguration if the config is not set.
In other words, the generator needs the config to exist to generate the config...
I don't know why this happens to some people, when it seems to work fine for others, but I worked around the problem by manually creating the initializer and copy/paste the template:
# config/initializers/doorkeeper.rb
Doorkeeper.configure do
# Change the ORM that doorkeeper will use (needs plugins)
orm :active_record
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
fail "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
# Put your resource owner authentication logic here.
# Example implementation:
# User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
# admin_authenticator do
# # Put your admin authentication logic here.
# # Example implementation:
# Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
# end
# Authorization Code expiration time (default 10 minutes).
# authorization_code_expires_in 10.minutes
# Access token expiration time (default 2 hours).
# If you want to disable expiration, set this to nil.
# access_token_expires_in 2.hours
# Assign a custom TTL for implicit grants.
# custom_access_token_expires_in do |oauth_client|
# oauth_client.application.additional_settings.implicit_oauth_expiration
# end
# Use a custom class for generating the access token.
# https://github.com/doorkeeper-gem/doorkeeper#custom-access-token-generator
# access_token_generator '::Doorkeeper::JWT'
# The controller Doorkeeper::ApplicationController inherits from.
# Defaults to ActionController::Base.
# https://github.com/doorkeeper-gem/doorkeeper#custom-base-controller
# base_controller 'ApplicationController'
# Reuse access token for the same resource owner within an application (disabled by default)
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
# reuse_access_token
# Issue access tokens with refresh token (disabled by default)
# use_refresh_token
# Provide support for an owner to be assigned to each registered application (disabled by default)
# Optional parameter confirmation: true (default false) if you want to enforce ownership of
# a registered application
# Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
# enable_application_owner confirmation: false
# Define access token scopes for your provider
# For more information go to
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
# default_scopes :public
# optional_scopes :write, :update
# Change the way client credentials are retrieved from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:client_id` and `:client_secret` params from the `params` object.
# Check out the wiki for more information on customization
# client_credentials :from_basic, :from_params
# Change the way access token is authenticated from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:access_token` or `:bearer_token` params from the `params` object.
# Check out the wiki for more information on customization
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
# Change the native redirect uri for client apps
# When clients register with the following redirect uri, they won't be redirected to any server and the authorization code will be displayed within the provider
# The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
# (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
#
# native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
# Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
# by default in non-development environments). OAuth2 delegates security in
# communication to the HTTPS protocol so it is wise to keep this enabled.
#
# force_ssl_in_redirect_uri !Rails.env.development?
# Specify what grant flows are enabled in array of Strings. The valid
# strings and the flows they enable are:
#
# "authorization_code" => Authorization Code Grant Flow
# "implicit" => Implicit Grant Flow
# "password" => Resource Owner Password Credentials Grant Flow
# "client_credentials" => Client Credentials Grant Flow
#
# If not specified, Doorkeeper enables authorization_code and
# client_credentials.
#
# implicit and password grant flows have risks that you should understand
# before enabling:
# http://tools.ietf.org/html/rfc6819#section-4.4.2
# http://tools.ietf.org/html/rfc6819#section-4.4.3
#
# grant_flows %w(authorization_code client_credentials)
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
# For example if dealing with a trusted application.
# skip_authorization do |resource_owner, client|
# client.superapp? or resource_owner.admin?
# end
# WWW-Authenticate Realm (default "Doorkeeper").
# realm "Doorkeeper"
end
Maybe something was changed in Rails 5 for generators, need to see Rails changelogs
When I was experimenting with it, it worked fine on a brand new rails app, but failed when trying to install it on an existing one. Perhaps there is another gem that is interacting.
@olbrich could you please provide a Gemfile that was used when the problem occurs? As I said before, I can't reproduce it on my existing project.
@nbulaj
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use Puma as the app server
#gem 'puma', '~> 3.7'
# CUSTOMIZATION
# unicorn server for rails https://rubygems.org/gems/unicorn-rails/versions/2.2.0
gem 'unicorn'
# CUSTOMIZATION
# Use mysql2 as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# CUSTOMIZATION
# api documentation, see https://github.com/Apipie/apipie-rails
gem 'apipie-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# CUSTOMIZATION
# for precompilation https://github.com/rails/execjs
# need javascript runtime
gem 'execjs'
# CUSTOMIZATION
# javascript runtime, needed by execjs https://github.com/cowboyd/therubyracer
gem 'therubyracer'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
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.0.5', '< 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]
# CUSTOMIZATION
gem 'uuidtools'
# CUSTOMIZATION
# https://github.com/sferik/rails_admin
gem 'rails_admin'
# CUSTOMIZATION
gem 'shoulda-matchers'
# CUSTOMIZATION
# https://github.com/kwatch/erubis
gem 'erubis'
# CUSTOMIZATION
group :test do
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'ffaker'
gem 'faker'
gem 'rubocop'
end
# CUSTOMIZATION
gem 'doorkeeper'
For an existing rails app i added doorkeeper and it fails.
For a fresh rails app it works fine.
Both using Rails 5.1.1 ruby 2.4.1p111.
Hope this helps to figure out the problem.
I also get this error on an existing Rails 4.2.8 app, Ruby 2.3.1
@homanchou @olbrich @agrohmann @Ninigi there is a fix for Doorkeeper already in master for deffered loading of AR models. Who knows, maybe some initializer in existing project caused an error by triggering some AR features. Can anybody try current master to test if this issue still exists??
@agrohmann I've tried with your Gemfile, but everything seems to be OK:
$ rails generate doorkeeper:install
create config/initializers/doorkeeper.rb
create config/locales/doorkeeper.en.yml
route use_doorkeeper
...
I think some gem or initializer is doing something that calls Doorkeeper before it initialized.. Can you provider a list of your initializers please?
Can't reproduce the issue, so I'm closing this issue due to lack of activity. If somebody wants to reopen it - please, provide maximum information bout the env, doorkeeper initializer, Gemfile.lock and other useful data
I was facing the exact issue, and found the solution.
It could fail if you have config.eager_load = true in config/environments/development.rb
If you closely look at the stack-trace of error below, it's clear that doorkeeper/application_controller is being called by eager_load! in engine.rb. So, I went to config/environments/developement.rb and set config.eager_load = false, and then rails g doorkeeper:install worked smoothly.
I think some gem or initializer is doing something that calls Doorkeeper before it initialized
Thanks @nbulaj for the subtle hint.
/home/prvithani/.rvm/gems/ruby-2.4.2/bundler/gems/doorkeeper-a7f850ac26dd/lib/doorkeeper/config.rb:18:in `configuration': Configuration for doorkeeper missing. Do you have doorkeeper initializer? (Doorkeeper::MissingConfiguration)
from /home/prvithani/.rvm/gems/ruby-2.4.2/bundler/gems/doorkeeper-a7f850ac26dd/app/controllers/doorkeeper/application_controller.rb:3:in `<module:Doorkeeper>'
from /home/prvithani/.rvm/gems/ruby-2.4.2/bundler/gems/doorkeeper-a7f850ac26dd/app/controllers/doorkeeper/application_controller.rb:1:in `<top (required)>'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:477:in `load'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:477:in `block in load_file'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:662:in `new_constants_in'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:476:in `load_file'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:374:in `block in require_or_load'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:36:in `block in load_interlock'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:36:in `load_interlock'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:357:in `require_or_load'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:335:in `depend_on'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:251:in `require_dependency'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:475:in `each'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:475:in `block in eager_load!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:473:in `each'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:473:in `eager_load!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/engine.rb:354:in `eager_load!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/application/finisher.rb:67:in `each'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/initializable.rb:30:in `instance_exec'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/initializable.rb:30:in `run'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/initializable.rb:59:in `block in run_initializers'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `each'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `call'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
from /home/prvithani/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/initializable.rb:58:in `run_initializers'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/application.rb:353:in `initialize!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/railtie.rb:185:in `public_send'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/railtie.rb:185:in `method_missing'
from /home/prvithani/Workspace/adwyze/config/environment.rb:18:in `<top (required)>'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:292:in `require'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:292:in `block in require'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:258:in `load_dependency'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:292:in `require'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/application.rb:329:in `require_environment!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/command/actions.rb:16:in `require_application_and_environment!'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/commands/generate/generate_command.rb:8:in `help'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/commands/generate/generate_command.rb:17:in `perform'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/command/base.rb:63:in `perform'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/command.rb:44:in `invoke'
from /home/prvithani/.rvm/gems/ruby-2.4.2/gems/railties-5.1.5/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
This just happened to me; and the reason was because I already had the use_doorkeeper statement in the routes.rb.
Deleting that line fixed it 馃槃
Most helpful comment
I was facing the exact issue, and found the solution.
It could fail if you have
config.eager_load = trueinconfig/environments/development.rbIf you closely look at the stack-trace of error below, it's clear that
doorkeeper/application_controlleris being called byeager_load!inengine.rb. So, I went toconfig/environments/developement.rband setconfig.eager_load = false, and thenrails g doorkeeper:installworked smoothly.Thanks @nbulaj for the subtle hint.