Fixing "Command Not Found" After Installing a CLI AI Coding Assistant

    This guide explains why the "command not found" error appears after installing a command-line AI coding assistant, and why a generic PATH fix often fails. It covers a three-step process for Linux, macOS, and Windows: locate the executable, update PATH in the correct file, and verify the result. It also covers version conflicts and broken paths after runtime upgrades.

    Fixing “Command Not Found” After Installing a CLI AI Coding Assistant

    Introduction: A Common Problem That Is Often Explained Incorrectly

    Many developers install a command-line AI coding assistant, run its start command, and get a single error line. On Linux or macOS it reads command not found. On Windows it reads '...' is not recognized as an internal or external command. Search results for this error usually give the same fix: append a specific directory to the PATH environment variable.

    Do not apply that fix without checking first. For some people it works. For others it does nothing, and the repeated edits make the problem harder to diagnose. The reason is that most tutorials assume the tool is installed in one particular directory. In fact, the location of the executable depends on how you installed the tool. Changing PATH without knowing that location is like sending a package without knowing the address.

    This article explains the cause of the error and provides a standard troubleshooting process for Linux, macOS, and Windows. The process has three steps: locate the file, configure PATH, and verify the result.

    1. What the Error Means: How the PATH Lookup Works

    To fix the error, you first need to understand how the shell finds a command. When you type a command and press Enter, the shell checks each directory listed in the PATH environment variable, in order, for an executable with that name. If it finds one, it runs it. If it checks every directory and finds nothing, it prints “command not found.” The Windows Command Prompt and PowerShell use the same lookup logic, but they show a different error message.

    This error has only two root causes:

    1. The tool was not installed successfully. The executable does not exist on disk.
    2. The tool is installed, but its directory is not in PATH. The shell cannot find it.

    The generic advice to “add a certain directory to PATH” only addresses a subset of the second case. If the tool is installed in a different directory, adding an empty directory to PATH has no effect.

    2. Why the Install Location Depends on the Install Method

    The same tool can place its executable in different locations depending on the installation channel. The table below shows common installation methods and their typical locations.

    Installation method Typical executable location
    Official install script .local/bin under the home directory
    System package manager (newer chip architectures) A dedicated bin directory under /opt
    System package manager (older chip architectures) /usr/local/bin
    Language package manager, global install A global bin directory whose path changes with the runtime version
    Windows installer An application folder under the user’s AppData directory

    Only the official install script typically places files in .local/bin under the home directory. If you installed the tool with a system package manager, the executable is probably under /opt or /usr/local. In that case, adding .local/bin to PATH adds a directory that does not contain the tool, so the error will remain. A global install through a language package manager is more complicated. The bin directory path changes with the runtime version, and after a runtime upgrade, an old path can become invalid.

    The conclusion is clear: before you change PATH, find out where the file actually is.

    3. Locate the Executable First

    Regardless of operating system or install method, start by locating the executable. On Unix-like systems, run:

    1. which -a your-command

    The -a option lists every match in PATH. The output determines the next step.

    Case 1: A path is printed. The tool is already in PATH and should work. If it still fails, another program with the same name is probably installed, and the shell is running the broken copy. Go to the “Version Conflicts” section in Section 6.

    Case 2: No output. The tool is not in PATH. Next, determine whether the tool is installed but missing from PATH, or not installed at all. Check the common installation locations:

    1. ls -la ~/.local/bin/your-command # official install script
    2. ls -la /opt/*/bin/your-command # package manager (newer chip architectures)
    3. ls -la /usr/local/bin/your-command # package manager (older chip architectures)

    If you installed the tool with a language package manager, use that manager’s list command to find the global install records and the bin directory. The directory that contains the real executable is the one to add to PATH. If none of the locations contain the file, the installation failed. Run the installation again and read the error messages carefully. Do not keep changing environment variables.

    On Windows, use the where command to search for the executable, or check the user directory where the installer usually writes files.

    4. Write the PATH Configuration Correctly

    After you find the real directory, update PATH. Several details are often missed in tutorials.

    1. Edit the correct configuration file. Bash users should edit ~/.bashrc or ~/.bash_profile. Zsh users should edit ~/.zshrc. Many cases of “the change has no effect” happen because the change was written to a file that the current shell does not load. Run echo $SHELL to confirm which shell you use.

    2. Append to PATH instead of overwriting it. The correct syntax is:

    1. export PATH="$PATH:/actual/located/bin/directory"

    Do not write export PATH="/some/directory". That line replaces all existing paths, and many basic commands will stop working.

    3. Reload the configuration. After you edit the file, run source ~/.zshrc (or the file you edited) to reload it. You can also open a new terminal window. Testing in an old session shows the old environment.

    4. On Windows. Edit Path in the graphical interface under System Properties, Environment Variables. Alternatively, use the setx command to write a user-level variable. Either way, open a new terminal window for the change to take effect.

    5. Verify and Wrap Up

    After you update the configuration, run these three checks in order:

    1. which your-command # should print the expected path
    2. your-command --version # should print the version number
    3. echo $PATH # confirm the new directory is present and the existing paths are intact

    The problem is fixed only when all three checks pass. If which finds the command but it still fails, check two things. First, confirm the file has execute permission (chmod +x). Second, check whether the file is a symbolic link that points to a missing target. Use ls -la to see where the arrow points.

    6. Advanced Pitfalls: Version Conflicts and Broken Paths

    Two common problems are worth watching for.

    Version conflicts. If you installed the tool once with an install script and once with a package manager, the older version earlier in PATH may be broken. The command then appears to exist but cannot run. Remove the extra copies so that only one remains. If needed, run hash -r to clear the shell’s command cache. Many people do not realize that the shell caches command locations. After you change PATH, the stale cache can still send you to the old executable.

    Broken paths after runtime upgrades. Tools installed globally with a language package manager often have bin directories that include a version number. After you upgrade the runtime, the old directory may be removed, and the old PATH entry stops working. The best practice is to use the package manager’s own command to get the current bin path and write that path to your configuration. Avoid hardcoding a path that contains a version number.

    Conclusion

    “Command not found” is not a problem you solve by memorizing one answer. It tests how well you understand how the environment variable lookup works. Keep this principle in mind: first locate the file, then decide how to change PATH, and finally verify the result and remove conflicts. With this process, you can troubleshoot most command-line tools on any operating system within minutes, without trial and error across conflicting tutorials. Environment setup skills like these are basic but useful in everyday development and in cloud operations, from container platforms to logging and monitoring.