hashicorp/vagrant · error · Vagrant::Errors::AliasInvalidError
The defined alias is not valid. Please review the informatio
Error message
The defined alias is not valid. Please review the information below to help resolve the issue:
Alias: %{alias}
Message: %{message} What it means
AliasInvalidError is raised by Vagrant::Alias#interpret (lib/vagrant/alias.rb:39) when parsing a line of the user's aliases file and the keyword portion (text left of '=') contains whitespace. The keyword must be a single shell-like token because it is registered as a CLI command override via @aliases.register(keyword.to_sym).
Source
Thrown at lib/vagrant/alias.rb:39
end
end
end
# This returns all the registered alias commands.
def commands
@aliases
end
# This interprets a raw line from the aliases file.
def interpret(line)
# is it a comment?
return nil if line.strip.start_with?("#")
keyword, command = line.split("=", 2).collect(&:strip)
# validate the keyword
if keyword.match(/\s/i)
raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any whitespace."
end
[keyword, command]
end
# This registers an alias.
def register(keyword, command)
@aliases.register(keyword.to_sym) do
lambda do |args|
# directly execute shell commands
if command.start_with?("!")
return Util::SafeExec.exec "#{command[1..-1]} #{args.join(" ")}".strip
end
return CLI.new(command.split.concat(args), @env).execute
end
end
endView on GitHub (pinned to 35f3160f4a)
Solutions
- Edit ~/.vagrant.d/aliases (or the configured aliases file) and rewrite the keyword without whitespace, e.g. 'v-up = up'
- Use hyphens or underscores to join words in the keyword
- Remove or comment out (leading '#') any experimental line causing the failure, then re-add corrected
Example fix
# before (~/.vagrant.d/aliases) vagrant up all = up # after v-up = up
Defensive patterns
Strategy: validation
Validate before calling
# Validate aliases file before Vagrant parses it
Pathname.new(File.join(Vagrant.source_root ? Dir.pwd : Dir.home, '.vagrant.d', 'aliases')) rescue nil
path = File.join(ENV['VAGRANT_HOME'] || File.join(Dir.home, '.vagrant.d'), 'aliases')
if File.exist?(path)
File.readlines(path).each do |line|
next if line.strip.start_with?('#') || line.strip.empty?
keyword, = line.split('=', 2)
if keyword.nil? || keyword.match(/\s/)
raise "Fix alias line before launch: #{line.inspect}"
end
end
end Prevention
- Keep alias keywords single-token: letters, digits, hyphens, underscores only
- Lint the aliases file in dotfiles CI so whitespace keywords never reach Vagrant
When it happens
Trigger: A line like 'my alias = up' or 'v up=up' in ~/.vagrant.d/aliases: line.split("=", 2) yields keyword 'my alias' / 'v up', keyword.match(/\s/i) succeeds, and the error is raised with the offending line and message while Vagrant loads aliases at startup.
Common situations: Hand-editing the aliases file and using spaces in the keyword; copy-pasting alias examples written shell-style ('alias vup=...'); trailing tabs or double spaces introduced by editors.
Related errors
- There are errors in the configuration of this machine. Pleas
- The explicit capability host specified of '%{value}' could n
- There was an error loading a Vagrantfile. The file being loa
- There was an error loading a Vagrantfile. The file being loa
- The host implementation explicitly specified in your Vagrant
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/e52a3b8016a84c3a.
Report an issue: GitHub.