Skip to content

Commit 7cc5af5

Browse files
committed
Only require config/application.rb when Rails.application not set
MSP-10964 Allows other Rails::Applications to use the commands.
1 parent f9ab7f7 commit 7cc5af5

File tree

1 file changed

+5
-2
lines changed
  • lib/metasploit/framework/command

1 file changed

+5
-2
lines changed

lib/metasploit/framework/command/base.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ def self.require_environment!
4949
parsed_options.environment!
5050
ARGV.replace(parsed_options.positional)
5151

52-
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40
53-
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application')
52+
# allow other Rails::Applications to use this command
53+
if !defined?(Rails) || Rails.application.nil?
54+
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40
55+
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application')
56+
end
5457

5558
# have to configure before requiring environment because
5659
# config/environment.rb calls initialize! and the initializers will use

0 commit comments

Comments
 (0)