{"record":{"id":"21b2cf664bcc4354","repo":"hashicorp/vagrant","slug":"there-was-an-error-parsing-the-vagrantfile-no-con","errorCode":null,"errorMessage":"There was an error parsing the Vagrantfile:\nNo config was given for the trigger(s) %{command}.","messagePattern":"There was an error parsing the Vagrantfile:\nNo config was given for the trigger\\(s\\) %(.+?)\\.","errorType":"exception","errorClass":"Vagrant::Errors::TriggersNoBlockGiven","httpStatus":null,"severity":"error","filePath":"plugins/kernel_v2/config/trigger.rb","lineNumber":60,"sourceCode":"      # trigger\n      #\n      # @param [Symbol] command Vagrant command to create trigger on\n      # @param [Block] block The defined before block\n      def before(*command, &block)\n        command.flatten!\n        blk = block\n\n        if command.last.is_a?(Hash)\n          if block_given?\n            extra_cfg = command.pop\n          else\n            # We were given a hash rather than a block,\n            # so the last element should be the \"config block\"\n            # and the rest are commands for the trigger\n            blk = command.pop\n          end\n        elsif !block_given?\n          raise Vagrant::Errors::TriggersNoBlockGiven,\n            command: command\n        end\n\n        command.each do |cmd|\n          trigger = create_trigger(cmd, blk, extra_cfg)\n          @_before_triggers << trigger\n        end\n      end\n\n      # Reads in and parses Vagrant command whitelist and settings for a defined\n      # trigger\n      #\n      # @param [Symbol] command Vagrant command to create trigger on\n      # @param [Block] block The defined after block\n      def after(*command, &block)\n        command.flatten!\n        blk = block\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/kernel_v2/config/trigger.rb#L42-L78","documentation":"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\").","triggerScenarios":"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.","commonSituations":"Forgetting the block while refactoring a Vagrantfile; assuming a command-only trigger is valid; losing the do...end during copy-paste from docs.","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"],"exampleFix":"# before\nconfig.trigger.before :up\n\n# after\nconfig.trigger.before :up do |t|\n  t.info = \"pre-up message\"\nend\n\n# alternatively, hash form\nconfig.trigger.before :up, info: \"pre-up message\"","handlingStrategy":"validation","validationCode":"# cheap smoke test before any vagrant command\nvagrant validate","typeGuard":null,"tryCatchPattern":"begin\n  Vagrant::Environment.new(cwd: project_dir).cli(\"status\")\nrescue Vagrant::Errors::TriggersNoBlockGiven => e\n  abort \"Trigger missing config block: #{e.message}\"\nend","preventionTips":["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"],"tags":["vagrant","triggers","vagrantfile","config","dsl"],"backgroundTag":"missing-block-argument","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}