diff --git a/lib/train.rb b/lib/train.rb index 960f9b53..e20e2961 100644 --- a/lib/train.rb +++ b/lib/train.rb @@ -116,6 +116,12 @@ def self.parse_uri(string) def self.validate_backend(conf, default = :local) return default if conf.nil? res = conf[:backend] + + if (res.nil? || res == 'localhost') && conf[:sudo] + fail Train::UserError, 'Sudo is only valid when running against a remote host. '\ + 'To run this locally with elevated privileges, run the command with `sudo ...`.' + end + return res if !res.nil? if !conf[:target].nil?