Troubleshooting “Command Not Found” After Installing an AI Coding Tool via CLI

    This guide explains why a terminal reports "command not found" after installing an AI coding tool from the command line, and how to fix it. Instead of blindly appending directories to PATH, you will learn a systematic workflow: locate the actual executable, identify where your installation method places binaries, modify PATH correctly, handle multi-install conflicts, and verify the fix without disrupting your existing environment.

    Symptom and Root Cause: Why the Terminal “Cannot Find Your Command”

    After installing an AI coding tool, running its command in a terminal often produces one of two errors: command not found on Unix-like systems, or “is not recognized as an internal or external command” on desktop operating systems. Many tutorials suggest appending a fixed directory to PATH, such as $HOME/.local/bin. This works for some installation methods but is completely ineffective for others, and can lead your troubleshooting in the wrong direction.

    The underlying cause is straightforward: the shell only searches the directories listed in the PATH environment variable, in order, for an executable file. If the directory containing your command is not in PATH, the shell reports “command not found.” But where the executable ends up depends entirely on how you installed it: a native installation script, a system package manager, or a language runtime’s global package manager can each place the binary in different locations. Only with certain installation methods will the executable land in $HOME/.local/bin. If your actual installation directory is elsewhere, blindly appending that path merely adds an empty or irrelevant directory to PATH, and the error will persist.

    The correct order of operations is: locate first, then decide, and only then modify PATH. Do not start editing configuration files.

    In the examples below, toolcmd is a placeholder for your AI coding tool’s actual command name.

    Step 1: Locate the Real Path of the Executable

    On Unix-like systems, first use the shell’s built-in lookup capabilities to check whether the command is already in PATH:

    1. command -v toolcmd
    2. type -a toolcmd

    type -a lists all matches in the current PATH, which is useful for identifying multiple installations. If it outputs a path, at least one executable is already on PATH. If the output is empty, PATH truly does not include it. On desktop operating systems, use the system’s search command:

    1. where toolcmd

    Based on the output, handle each case:

    1. A path is printed: The command is already in PATH. If it still fails, focus on possible multiple-install conflicts, stale command caching, a terminal that needs restarting, insufficient permissions, or architecture mismatches.
    2. No output at all: Determine whether the tool was installed but its directory isn’t in PATH, or whether it was never installed at all. Do not guess — check common installation locations for the file.

    On Unix-like systems:

    1. ls -l "$HOME/.local/bin/toolcmd"
    2. ls -l /usr/local/bin/toolcmd
    3. ls -l /opt/pkg/bin/toolcmd

    On desktop operating systems, check the user profile and common program directories:

    1. dir "%USERPROFILE%\.local\bin\toolcmd.exe"
    2. dir "%LOCALAPPDATA%\Programs\toolcmd\toolcmd.exe"

    If you used a language runtime’s package manager for a global install, also query its global executable directory. The command varies by runtime; understand the concept as:

    1. <runtime package manager> global bin

    Whichever check command returns a real file path, that file’s directory is what needs to be added to PATH. If none of these locations contain the file, the problem is not PATH — return to the installation step: confirm whether the installation command succeeded, whether it installed for the current user, whether it was interrupted due to permissions or network issues, or whether the installer only completed partially.

    How Installation Methods Affect Path Location

    Common installation methods generally fall into three categories:

    • Native installation scripts: May install to a user-level directory such as $HOME/.local/bin, or to a system-level directory.
    • System package managers: Typically install into the package manager’s own prefix. Different CPU architectures or different package managers may use different prefixes; do not assume it is always /usr/local/bin.
    • Language runtime global installs: Executables are usually placed in the runtime’s global bin directory, which may change as the runtime version switches.

    Therefore, PATH configuration cannot be separated from the installation method. A safer practice is to note where you installed the tool from and immediately locate the binary with command -v, type -a, or where once installation finishes. Only modify PATH after you have confirmed the file’s actual location.

    How to Modify PATH Correctly

    On Unix-like systems, first verify the change temporarily:

    1. export PATH="/actual/directory:$PATH"
    2. toolcmd --version

    If that works, write it into your current shell’s configuration file. The configuration file varies by shell, so do not blindly use a fixed filename:

    1. echo 'export PATH="/actual/directory:$PATH"' >> <your shell’s config file>

    After editing, open a new terminal or source the configuration, then verify with command -v toolcmd. Always append to PATH rather than overwriting it, and back up the configuration file before making changes.

    On desktop operating systems, prefer adding the directory through the graphical interface: System Properties → Environment Variables → User Variables → Path. Avoid using command-line overrides that might truncate the existing PATH. If you do edit via the command line, back up the current PATH first and watch for length limits. After modifying, you must open a new terminal — old terminals retain the previous environment variables.

    On remote terminals such as cloud-hosted VMs, note that the environment variables for the login user and for the user you switch to (e.g., via su) may differ. A tool installed for one user should not be assumed to work for another; configure PATH in the environment of the user who will actually run the command.

    Handling Multiple Installations and Conflicts

    If type -a toolcmd lists multiple paths, you have multiple installations. Directories earlier in PATH take precedence, which may cause an older or incomplete version to be invoked. To resolve this: remove the unwanted installation, or reorder PATH so the target version’s directory comes first. Then refresh the command cache and open a new terminal to verify. Use toolcmd --version to confirm which version is actually being executed.

    Also check three non-PATH issues: whether the file exists and is complete; whether it has executable permission (on Unix-like systems); and whether the package architecture matches the current system. If permissions are insufficient, add the executable bit to the target file. If the architecture is incompatible, reinstall the correct version.

    Verification, Rollback, and Best Practices

    After fixing the issue, verify in this order: open a new terminal; run command -v toolcmd or where toolcmd to confirm the path; run toolcmd --version to confirm it runs; check that PATH was appended to, not overwritten. If other commands break after your change, restore the backup of your configuration file or environment variables, remove the appended line, and reopen a terminal.

    Best practices are: locate the real path immediately after installation; stick to one installation source rather than mixing multiple; only append to PATH, never overwrite it; back up before editing; verify in the target user and target terminal environment; and apply the same principles to both cloud VMs and local terminals. Following this process will resolve “command not found” without making your environment messier.