hashicorp/vagrant · error · Vagrant::Errors::TriggersNoBlockGiven
There was an error parsing the Vagrantfile: No config was gi
Error message
There was an error parsing the Vagrantfile:
No config was given for the trigger(s) %{command}. What it means
TriggerConfig#before raises TriggersNoBlockGiven when a before trigger lists one or more commands but carries no configuration: the call supplied neither a block nor a trailing Hash. The trigger DSL accepts settings only as `do |trigger| ... end` or as a Hash in the last argument position (e.g. config.trigger.before :up, name: "x").
Source
Thrown at plugins/kernel_v2/config/trigger.rb:60
# trigger
#
# @param [Symbol] command Vagrant command to create trigger on
# @param [Block] block The defined before block
def before(*command, &block)
command.flatten!
blk = block
if command.last.is_a?(Hash)
if block_given?
extra_cfg = command.pop
else
# We were given a hash rather than a block,
# so the last element should be the "config block"
# and the rest are commands for the trigger
blk = command.pop
end
elsif !block_given?
raise Vagrant::Errors::TriggersNoBlockGiven,
command: command
end
command.each do |cmd|
trigger = create_trigger(cmd, blk, extra_cfg)
@_before_triggers << trigger
end
end
# Reads in and parses Vagrant command whitelist and settings for a defined
# trigger
#
# @param [Symbol] command Vagrant command to create trigger on
# @param [Block] block The defined after block
def after(*command, &block)
command.flatten!
blk = block
View on GitHub (pinned to 35f3160f4a)
Solutions
- Add a block: config.trigger.before :up do |t| t.info = "msg" end
- Or pass settings as a trailing Hash: config.trigger.before :up, info: "msg"
- Run `vagrant validate` to confirm the Vagrantfile parses before other commands
Example fix
# before config.trigger.before :up # after config.trigger.before :up do |t| t.info = "pre-up message" end # alternatively, hash form config.trigger.before :up, info: "pre-up message"
Defensive patterns
Strategy: validation
Validate before calling
# cheap smoke test before any vagrant command vagrant validate
Try / catch
begin
Vagrant::Environment.new(cwd: project_dir).cli("status")
rescue Vagrant::Errors::TriggersNoBlockGiven => e
abort "Trigger missing config block: #{e.message}"
end Prevention
- Treat a trigger declaration as incomplete without a block or trailing Hash
- Standardize on the block form for readability
- Run `vagrant validate` in CI to catch missing do...end blocks
When it happens
Trigger: Writing `config.trigger.before :up` or `config.trigger.before [:up, :halt]` with no do...end block; also argument orders where the options Hash is not last, so the trailing argument is a command symbol instead of a Hash.
Common situations: Forgetting the block while refactoring a Vagrantfile; assuming a command-only trigger is valid; losing the do...end during copy-paste from docs.
Related errors
- There was an error loading a Vagrantfile. The file being loa
- There was an error loading a Vagrantfile. The file being loa
- There are errors in the configuration of this machine. Pleas
- The specified Vagrantfile to clone from was not found. Pleas
- There was an error loading a Vagrantfile. The file being loa
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/21b2cf664bcc4354.
Report an issue: GitHub.