You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac OSX常见命令无法使用问题咨询

Fixing "command not found" Errors & Understanding Your PATH Issue

Hey there! Let's work through this together—this is a super common hiccup when you're new to the terminal, especially with misconfigured environment variables like PATH.

What That PATH Message Means

First off, a quick correction: to check your PATH properly, you should run echo $PATH, not just type $PATH directly. When you run $PATH as a command, the terminal tries to execute whatever value is stored in the PATH variable. In your case, that value is /usr/local/Cellar/smlnj/110.82/—a directory, not an executable file—so the terminal throws that "is a directory" error to let you know it can't run a folder like a program.

Worse, your PATH is currently set to only include that smlnj directory. Normally, PATH is a colon-separated list of directories where the terminal looks for commands (like date, brew, etc.). System default commands live in places like /bin and /usr/bin, which aren't in your PATH right now—that's why basic commands like date are failing with "command not found".

Step 1: Restore Basic Command Access

Let's fix your PATH temporarily first so you can use normal commands again. Run this in your terminal:

export PATH="/bin:/usr/bin:/usr/local/bin:$PATH"

This adds the system's default command directories (and Homebrew's directory, since you have smlnj installed via Homebrew) to your PATH. Now you should be able to run date, brew, and other basic commands without errors.

Step 2: Fix Your Permanent PATH Configuration

To make this change stick, you need to edit the shell configuration file that's setting your PATH incorrectly. Depending on which shell you're using:

  • If you use Bash: edit ~/.bashrc or ~/.bash_profile
  • If you use Zsh: edit ~/.zshrc

Open the file with a text editor (like nano ~/.zshrc if you're on Zsh) and look for a line that looks like:

export PATH="/usr/local/Cellar/smlnj/110.82/"

This line is overwriting your entire PATH with just the smlnj directory. Change it to add smlnj's bin folder (where its executable files live) to your existing PATH instead:

export PATH="/usr/local/Cellar/smlnj/110.82/bin:$PATH"

Save the file, then run source ~/.zshrc (or the corresponding file for your shell) to apply the changes immediately.

Step 3: Uninstall smlnj

Now that your PATH is fixed, you can uninstall smlnj using Homebrew (since it's installed in /usr/local/Cellar, which is Homebrew's default location). Run this command:

brew uninstall smlnj

If you still get "command not found" for brew, double-check that /usr/local/bin is in your PATH (we added it in Step 1, so it should be). Once uninstalled, you can also remove that smlnj PATH line from your shell config if you don't plan to reinstall it later.

内容的提问来源于stack exchange,提问作者Solo lolo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:03:32