hashicorp/vagrant · error · VagrantPlugins::HerokuPush::Errors::CommandFailed
The following command exited with a non-zero exit status:
Error message
The following command exited with a non-zero exit status:
%{cmd}
stdout: %{stdout}
stderr: %{stderr} What it means
Every git invocation in the Heroku push goes through execute!, which streams stdout/stderr to the UI and raises Errors::CommandFailed when the subprocess exits non-zero. The message interpolates the joined command line plus captured stdout and stderr, so the underlying git failure text is preserved verbatim.
Source
Thrown at plugins/pushes/heroku/push.rb:137
# @return [String]
def heroku_git_url(app)
"git@heroku.com:#{app}.git"
end
# Execute the command, raising an exception if it fails.
# @return [Vagrant::Util::Subprocess::Result]
def execute!(*cmd)
subproccmd = cmd.dup << { notify: [:stdout, :stderr] }
result = Vagrant::Util::Subprocess.execute(*subproccmd) do |type, data|
if type == :stdout
@env.ui.info(data, new_line: false)
elsif type == :stderr
@env.ui.warn(data, new_line: false)
end
end
if result.exit_code != 0
raise Errors::CommandFailed,
cmd: cmd.join(" "),
stdout: result.stdout,
stderr: result.stderr
end
result
end
end
end
end
View on GitHub (pinned to 35f3160f4a)
Solutions
- Read the stderr field — it is the real git error (authentication, refs, network)
- Reproduce by running the printed command manually in the project directory
- Ensure Heroku auth works (heroku login / valid netrc) and the app exists
- Verify config.branch and config.remote in the push block match reality (branch exists, remote resolvable)
- Commit before pushing — the repo needs a HEAD for branch detection
Example fix
# before config.push.define "heroku" do |p| p.app = "myapp" p.branch = "develop" # branch does not exist -> git push fails end # after config.push.define "heroku" do |p| p.app = "myapp" p.branch = "main" end
Defensive patterns
Strategy: try-catch
Validate before calling
# preflight the pieces execute! will run
%w[git].each { |b| abort "#{b} missing" if Vagrant::Util::Which.which(b).nil? }
system("git -C . rev-parse --verify HEAD >/dev/null") or abort "no commits to push" Try / catch
begin
env.cli(%w(push heroku))
rescue VagrantPlugins::HerokuPush::Errors::CommandFailed => e
d = e.extra_data
abort "git failed (#{d[:cmd]})\nstderr: #{d[:stderr]}"
end Prevention
- Authenticate to Heroku (heroku login / netrc) before pushing
- Ensure config.branch exists and the repo has an initial commit
- Reproduce the failing git command manually when diagnosing
When it happens
Trigger: Any of the wrapped git calls failing: git_push_heroku running `git --git-dir ... --work-tree ... push <remote> <branch>:master` (auth failure, nonexistent Heroku app, rejected push), has_git_remote? / add_heroku_git_remote failing, or git_branch's symbolic-ref on a repo with no commits (unborn HEAD).
Common situations: Not logged in to Heroku (missing credentials in ~/.netrc); config.app naming a deleted app; config.branch set to a branch that doesn't exist; pushing a repo with no initial commit; network failures reaching git.heroku.com.
Related errors
- The Git binary '%{bin}' could not be found. Please ensure yo
- The following path is not a valid Git repository: %{pat
- Vagrant was unable to find the Atlas uploader CLI. If your V
- The push strategy '%{name}' is not defined in the Vagrantfil
- There are no push strategies named '%{name}'. Please make su
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/f744aacf2798d403.
Report an issue: GitHub.