hashicorp/vagrant · error · VagrantPlugins::HerokuPush::Errors::NotAGitRepo
The following path is not a valid Git repository: %{pat
Error message
The following path is not a valid Git repository:
%{path}
Please ensure you are working in the correct directory. In order to use
the Vagrant Heroku Push plugin, you must have a git repository. What it means
The Heroku push builds everything from a git repository at config.dir (default '.'). verify_git_repo! checks File.directory?("#{path}/.git") and raises Errors::NotAGitRepo with %{path} when that directory does not exist. Because it tests for a .git directory, git worktrees/submodules (where .git is a file) also trip it.
Source
Thrown at plugins/pushes/heroku/push.rb:50
# Push to Heroku
git_push_heroku(config.remote, branch, dir)
end
# Verify that git is installed.
# @raise [Errors::GitNotFound]
def verify_git_bin!(path)
if Vagrant::Util::Which.which(path).nil?
raise Errors::GitNotFound, bin: path
end
end
# Verify that the given path is a git directory.
# @raise [Errors::NotAGitRepo]
# @param [String]
def verify_git_repo!(path)
if !File.directory?(git_dir(path))
raise Errors::NotAGitRepo, path: path
end
end
# Interpret the name of the Heroku application from the given path.
# @param [String] path
# @return [String]
def interpret_app(path)
File.basename(path)
end
# The git directory for the given path.
# @param [String] path
# @return [String]
def git_dir(path)
"#{path}/.git"
end
# The name of the current git branch.View on GitHub (pinned to 35f3160f4a)
Solutions
- Run vagrant push from a real git clone (git init + commit if starting fresh)
- Check the push block's dir option points at the repo root containing .git
- If using a git worktree or submodule, push from the main checkout instead — the .git file layout fails File.directory?
- For non-git workflows, use the ftp/local push strategy instead of heroku
Example fix
# before config.push.define "heroku" do |p| p.dir = "./dist" # no dist/.git -> NotAGitRepo end # after git init && git add . && git commit -m "deploy" config.push.define "heroku" do |p| p.dir = "." # repo root with .git directory end
Defensive patterns
Strategy: validation
Validate before calling
dir = "." # or your push config.dir
abort "#{dir} is not a git repo" unless File.directory?(File.join(dir, ".git")) Type guard
def git_repo_dir?(path) File.directory?(File.join(path.to_s, ".git")) end
Try / catch
begin
env.cli(%w(push heroku))
rescue VagrantPlugins::HerokuPush::Errors::NotAGitRepo => e
abort "Push from a real git clone: #{e.extra_data[:path]}"
end Prevention
- Push only from a cloned repo, never from exported archives
- Note the .git-file (worktree/submodule) layout fails this check - use the main checkout
- Verify config.dir points at the repo root
When it happens
Trigger: Running vagrant push heroku from a directory without a .git directory: fresh template, extracted archive, or a linked worktree/submodule where .git is a file; or setting config.dir in the push block to a non-repo path.
Common situations: Deploying from an exported/zip'd source tree that was never git-cloned; worktrees; pointing dir at a build-output folder.
Related errors
- The Git binary '%{bin}' could not be found. Please ensure yo
- The following command exited with a non-zero exit status:
- 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/c0b2225df46fbb38.
Report an issue: GitHub.