{"record":{"id":"f744aacf2798d403","repo":"hashicorp/vagrant","slug":"the-following-command-exited-with-a-non-zero-exit","errorCode":null,"errorMessage":"The following command exited with a non-zero exit status:\n\n    %{cmd}\n\nstdout: %{stdout}\nstderr: %{stderr}","messagePattern":"The following command exited with a non-zero exit status:\n\n    %(.+?)\n\nstdout: %(.+?)\nstderr: %(.+?)","errorType":"exception","errorClass":"VagrantPlugins::HerokuPush::Errors::CommandFailed","httpStatus":null,"severity":"error","filePath":"plugins/pushes/heroku/push.rb","lineNumber":137,"sourceCode":"      # @return [String]\n      def heroku_git_url(app)\n        \"git@heroku.com:#{app}.git\"\n      end\n\n      # Execute the command, raising an exception if it fails.\n      # @return [Vagrant::Util::Subprocess::Result]\n      def execute!(*cmd)\n        subproccmd = cmd.dup << { notify: [:stdout, :stderr] }\n        result = Vagrant::Util::Subprocess.execute(*subproccmd) do |type, data|\n          if type == :stdout\n            @env.ui.info(data, new_line: false)\n          elsif type == :stderr\n            @env.ui.warn(data, new_line: false)\n          end\n        end\n\n        if result.exit_code != 0\n          raise Errors::CommandFailed,\n            cmd:    cmd.join(\" \"),\n            stdout: result.stdout,\n            stderr: result.stderr\n        end\n\n        result\n      end\n    end\n  end\nend\n","sourceCodeStart":119,"sourceCodeEnd":148,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/pushes/heroku/push.rb#L119-L148","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"# before\nconfig.push.define \"heroku\" do |p|\n  p.app = \"myapp\"\n  p.branch = \"develop\"   # branch does not exist -> git push fails\nend\n\n# after\nconfig.push.define \"heroku\" do |p|\n  p.app = \"myapp\"\n  p.branch = \"main\"\nend","handlingStrategy":"try-catch","validationCode":"# preflight the pieces execute! will run\n%w[git].each { |b| abort \"#{b} missing\" if Vagrant::Util::Which.which(b).nil? }\nsystem(\"git -C . rev-parse --verify HEAD >/dev/null\") or abort \"no commits to push\"","typeGuard":null,"tryCatchPattern":"begin\n  env.cli(%w(push heroku))\nrescue VagrantPlugins::HerokuPush::Errors::CommandFailed => e\n  d = e.extra_data\n  abort \"git failed (#{d[:cmd]})\\nstderr: #{d[:stderr]}\"\nend","preventionTips":["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"],"tags":["heroku","push","git","subprocess","deploy"],"backgroundTag":"git-push-failed","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}