hashicorp/vagrant · error · Vagrant::Errors::PushStrategyNotProvided

The Vagrantfile defines more than one 'push' strategy. Pleas

Error message

The Vagrantfile defines more than one 'push' strategy. Please specify a strategy. Defined strategy names are: %{pushes}

What it means

Raised by `vagrant push` when the Vagrantfile defines more than one `config.push.define` block but no strategy name was given on the command line. The command's validate_pushes! auto-selects a strategy only when exactly one is defined; with two or more it raises PushStrategyNotProvided and interpolates the defined names into the message. This is a usage/validation error, not a failure of any push backend.

Source

Thrown at plugins/commands/push/command.rb:62

      #
      # @param [Array<Symbol>] pushes
      #   the list of pushes defined by the environment
      # @param [String] name
      #   the name provided by the user on the command line
      #
      # @return [Symbol]
      #   the compiled list of pushes
      #
      def validate_pushes!(pushes, name = nil)
        if pushes.nil? || pushes.empty?
          raise Vagrant::Errors::PushesNotDefined
        end

        if name.nil?
          if pushes.length == 1
            return pushes.first.to_sym
          else
            raise Vagrant::Errors::PushStrategyNotProvided,
              pushes: pushes.map(&:to_s)
          end
        end

        name = name.to_sym
        if !pushes.include?(name)
          raise Vagrant::Errors::PushStrategyNotDefined,
            name: name.to_s,
            pushes: pushes.map(&:to_s)
        end

        return name
      end
    end
  end
end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Re-run with an explicit strategy: `vagrant push <name>` using one of the names listed in the error message
  2. Delete or comment out push blocks you do not use so exactly one remains and the bare `vagrant push` works again
  3. If multiple strategies are intentional, update scripts/CI to always pass the strategy name explicitly

Example fix

# before
config.push.define('ftp') do |push| ... end
config.push.define('local-exec') do |push| ... end
# vagrant push  ->  PushStrategyNotProvided

# after
# vagrant push ftp    (or)    vagrant push local-exec
Defensive patterns

Strategy: validation

Validate before calling

defined = File.readlines('Vagrantfile').count { |l| l.include?('push.define') }
abort 'multiple push strategies defined; run: vagrant push <name>' if defined > 1
system('vagrant push')

Try / catch

begin
  VagrantPlugins::CommandPush::Command.new(argv, env).execute
rescue Vagrant::Errors::PushStrategyNotProvided => e
  names = e.extra_data[:pushes]
  raise "specify one of: #{names.join(', ')}"
end

Prevention

When it happens

Trigger: Running `vagrant push` with no strategy argument while the Vagrantfile contains multiple push blocks (e.g. both `config.push.define 'ftp'` and `config.push.define 'local-exec'`). Programmatically, calling validate_pushes!(pushes) with a pushes array of length > 1 and name = nil.

Common situations: A team Vagrantfile keeps separate push strategies for staging and production; a developer who previously used a single-push Vagrantfile copies in a second block and re-runs the bare `vagrant push` command they had aliased or scripted.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/3720ab2f4db86493. Report an issue: GitHub.