{"record":{"id":"2e56882a48f8f840","repo":"Aider-AI/aider","slug":"gui-can-currently-only-be-used-inside-a-git-repo","errorCode":null,"errorMessage":"GUI can currently only be used inside a git repo","messagePattern":"GUI can currently only be used inside a git repo","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"aider/gui.py","lineNumber":75,"sourceCode":"            return\n\n        self.keys.add(key)\n        setattr(self, key, val)\n        return True\n\n\n@st.cache_resource\ndef get_state():\n    return State()\n\n\n@st.cache_resource\ndef get_coder():\n    coder = cli_main(return_coder=True)\n    if not isinstance(coder, Coder):\n        raise ValueError(coder)\n    if not coder.repo:\n        raise ValueError(\"GUI can currently only be used inside a git repo\")\n\n    io = CaptureIO(\n        pretty=False,\n        yes=True,\n        dry_run=coder.io.dry_run,\n        encoding=coder.io.encoding,\n    )\n    # coder.io = io # this breaks the input_history\n    coder.commands.io = io\n\n    for line in coder.get_announcements():\n        coder.io.tool_output(line)\n\n    return coder\n\n\nclass GUI:\n    prompt = None","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/Aider-AI/aider/blob/5dc9490bb35f9729ef2c95d00a19ccd30c26339c/aider/gui.py#L57-L93","documentation":"Streamlit GUI startup check in get_coder(): after building a Coder via cli_main(return_coder=True), coder.repo is None — the working directory is not a git repository — so the GUI refuses to run. The GUI's state and undo model depend on git.","triggerScenarios":"Running `python -m aider.gui` (or the gui command) from a directory outside any git repo; repo detection failing due to a missing .git or --no-git style settings; running inside a container/scratch dir.","commonSituations":"First-time users launching the GUI in their home directory or a fresh folder; CI/sandbox environments without git initialized; nested directories where the git root is above an unexpected boundary.","solutions":["cd into the project repo or run `git init` in the project directory, then restart the GUI","Pass the target directory explicitly (aider gui <path>) so repo detection starts from the right place","If git is intentionally unused, use the CLI instead of the GUI — the GUI requires a repo"],"exampleFix":"# before\n$ cd /tmp/playground && python -m aider.gui\n\n# after\n$ cd /tmp/playground && git init && python -m aider.gui\n","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef inside_git_repo(path: str = \".\") -> bool:\n    return subprocess.run(\n        [\"git\", \"-C\", path, \"rev-parse\", \"--is-inside-work-tree\"],\n        capture_output=True,\n    ).returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    coder = get_coder()\nexcept ValueError as e:\n    if \"inside a git repo\" in str(e):\n        st.error(\"Open a git repository to use the GUI (run `git init` first).\")\n        st.stop()\n    raise","preventionTips":["Launch the GUI from the project's git root or pass the repo path as an argument","Run git init in new projects before starting aider","Use the CLI (not the GUI) when you deliberately work outside git"],"tags":["aider","gui","git","startup"],"backgroundTag":null,"analyzedSha":"5dc9490bb35f9729ef2c95d00a19ccd30c26339c","analyzedAt":"2026-08-15T05:40:10.498Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}