Command Not Found After Installing an AI Coding Tool: A Practical Troubleshooting Guide
This guide explains why a newly installed AI coding tool still returns "command not found," and walks through a repeatable troubleshooting workflow: how the shell resolves commands via PATH, where executables land across different installation channels, how to locate the binary before editing configuration, how to resolve conflicts caused by multiple installations, and how to verify the fix. It also covers Windows-specific differences and long-term practices for keeping development environments reliable.
Introduction: “Command not found” doesn’t always mean a broken installation
You install an AI coding tool, type the launch command into your terminal, and expect an interactive interface. Instead, you get a cold error message: command not found on Unix-like systems, or “is not recognized as an internal or external command” in the Windows command prompt. Search results tend to give the same answer: append a directory to your environment variable configuration file.
The problem is that this advice only works for some people. If you installed the tool through a package manager or a script-based installer, following that advice changes nothing, and the error persists. Because you “followed the tutorial exactly,” the confusion only deepens.
The root cause is that most tutorials assume the tool lives in one fixed directory, but that is only one of several installation channels. Before you decide whether to modify your configuration, and where, you first need to know where the executable actually landed. This article breaks that process into a reusable troubleshooting workflow.
1. Understand the mechanism: how the shell finds a command
When you type a command name without a path, the shell does not scan the entire disk. It walks through the directories listed in the PATH environment variable in order, concatenating “directory + command name” and testing each candidate. The first executable match is handed to the system to load.
Two key conclusions follow from this:
- A “command not found” error tells you only one thing: no match for that name exists in any directory covered by
PATH. It does not prove the file is missing, and it does not prove the installation failed. PATHis ordered. When the same executable name appears in multiple directories, the earlier one shadows the later one. This explains a large number of cases where a tool “is installed but behaves strangely.”
Schematically, the value of PATH is a list of directories joined by colons (semicolons on Windows):
echo "$PATH"# /usr/local/bin:/usr/bin:/bin:/opt/homebrew/bin
Once you understand this, the troubleshooting approach shifts from blindly appending configuration to locating first and deciding second.
2. Different installation channels put the executable in different places
The same tool can land in very different locations depending on how it was installed. The common patterns are:
| Installation channel | Typical executable location |
|---|---|
| Official script-based installer | A local bin directory under the user’s home directory |
| System-level package manager (Apple Silicon) | /opt/homebrew/bin |
| System-level package manager (Intel-based Mac) | /usr/local/bin |
| Global install within a language runtime ecosystem | The global bin directory for that runtime version |
| Preinstalled by the system or an administrator | /usr/bin, /usr/local/bin |
The easiest trap is the global install within a language runtime ecosystem: the global bin directory changes when you switch runtime versions. Once a version manager switches versions, the old path becomes invalid and the command appears to “disappear.”
The conclusion is straightforward: only the official script-based installer uses a local bin directory under the user’s home. If you used a package manager but added the user’s local bin to PATH, that directory is empty, so adding it accomplishes nothing.
3. The first step is always to locate, not to change configuration
3.1 Check whether PATH can find it
which -a <command-name>
The -a flag lists every matching path, not just the first one. There are three possible outcomes:
- Output appears: the command is already in
PATHand usable. If you still get an error, multiple installations are most likely conflicting with each other. Go to section 4. - No output: it really is absent from
PATH. Move to 3.2 and check each location. - Multiple lines of output: go to section 4 immediately to resolve the conflict.
3.2 Check the common installation locations one by one
ls -l ~/.local/bin/<command-name> # script-based installerls -l /opt/homebrew/bin/<command-name> # package manager (Apple Silicon)ls -l /usr/local/bin/<command-name> # package manager (Intel-based)<runtime> -g ls <package-name> 2>/dev/null # runtime ecosystem global install
Whichever command prints a file, the directory containing that file is the target you need to add to PATH. Only if all of them come back empty is the installation itself at fault. In that case, return to the installation steps and check whether the install process reported an error, whether write permissions were missing, or whether a security policy blocked it.
3.3 Differences on Windows
Windows does not use the colon-separated configuration file logic of PATH. Instead, it maintains environment variables through the system or user-level environment variable interface, and changes take effect only in a newly opened terminal. You also need to distinguish terminal types: PowerShell, the traditional command interpreter, and Unix-like compatibility layers parse executable file extensions differently. It is common for the same entry point to work in one terminal and fail in another. When troubleshooting, first confirm which terminal the failure occurred in, then confirm whether the environment variables have been refreshed.
4. Advanced failure: version confusion caused by multiple installations
More troublesome than “not found” is “found but wrong.” A typical scenario: you installed one version earlier with a script, then installed another version through a package manager. Both directories are in PATH, and the earlier one takes effect, but your upgrade applies to the later one. The result is “I upgraded, but the version number didn’t change.”
The guiding principle is to converge on a single source:
- Use
which -ato list all matching paths. - Choose one channel as the sole source and uninstall the others.
- Clean up leftover symlinks and cache directories.
- Reopen the terminal and run
which -aagain to confirm only one path remains.
5. The fix and the verification loop
Once you have located the executable, decide the action based on whether the target directory is already in PATH:
# Target directory not in PATH: append it (zsh example)echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrcsource ~/.zshrc# Target directory already in PATH: do not append it again; resolve the conflict instead
Verification should form a closed loop, not stop once you have made the change:
which -a <command-name> # confirm the matching path is unique and correct<command-name> --version # confirm the version is what you expect
If it still fails, check three things in order: whether the configuration file is overridden by another snippet, whether you edited a shell configuration file you are not actually using, and whether you forgot to open a new terminal.
6. Turn one-off troubleshooting into a long-term standard
- Single installation source: keep only one installation channel per tool so the upgrade path stays controllable.
- Prefer user-level directories: this avoids polluting system directories and reduces permission problems.
- Keep configuration reversible: back up a copy before modifying environment variables so you can restore quickly if something breaks.
- Isolate runtimes with containers or separate environments: this eliminates the drift of global directories across versions at the root.
- Document an environment baseline within your team: new members and machine migrations can refer to it directly, reducing repeated troubleshooting.
For enterprise scenarios, you can also move this kind of environment validation earlier into the CI pipeline, using a self-check script at the startup stage to surface path and version problems in advance. Combined with centralized logging and monitoring alerts, this compresses environment-related failures—where things “run locally but fail in production”—into a shorter feedback cycle.
Conclusion
“Command not found” looks like an installation problem, but it is essentially a path resolution problem. Switch the order to locate first, judge second, modify last, and most cases converge within a few minutes. What is worth investing in is not memorizing one append command, but building three habits: a single installation source, reversible configuration, and a verifiable loop. These determine whether you troubleshoot a similar problem once or over and over again.
